#Condition acts differently between Debug/ReleaseSafe and ReleaseFast/ReleaseSmall

1 messages · Page 1 of 1 (latest)

candid stratus
#

I have this check in my code:

if (res.args.condition != null and res.args.width != null) {
            std.log.warn("Starting condition specified. Width setting ignored.", .{});
        }

I have the warning when I build with Debug or ReleaseSafe optimization flags:

zig-out\bin\zcellterm.exe -w 10 -c "0101010" 126
warning: Starting condition specified. Width setting ignored.
[rest of the program’s output]

But I don’t when I build with ReleaseFast or ReleaseSmall:

zig-out\bin\zcellterm.exe -w 10 -c "0101010" 126
[the program’s usual output with no warning beforehands]

I’m using zig-clap which I think is building the arguments parser at comptime. Is this a compiler bug? A zig-clap bug? Or is this intended behavior? Should I open a GitHub issue somewhere if there isn’t one already for this?

You can try to reproduce using this branch from my repo, there’s a debug print function in there (the readme isn’t up to date, but all the functions in --help are implemented)

https://github.com/Siphonay/zcellterm/tree/1.0.0-wip-debug

GitHub

Zig CLI implementation of the Wolfram Elementary Cellular Automaton - GitHub - Siphonay/zcellterm at 1.0.0-wip-debug

#

This happens both with 0.11.0 and master

light charm
#

I think the standard logging system only logs errors on ReleaseFast and ReleaseSafe.

candid stratus
#

Oooh

light charm
#

It's the default but you can override it in std_options on your root file.

candid stratus
#

Right, thanks!

Is it appropriate to use std.log to print these kind of messages though? Or should I just stick to writing to stderr

light charm
#

Depends on your use case.

#

The advantage of the logging system is that it's flexible and configurable.

#

So you can e.g. set it to log to file without changing the code that does the logging, or do something different for specific logging scopes.