#difference between log.info and Io.File.stdout().writeStreamingAll();
1 messages · Page 1 of 1 (latest)
first one writes to stdout, second one may write to stderr, stdout, a log file, a log server, ...
well, std.log.info will run through an application-defined logging function that may or may not print to the console. by default, it prints to stderr which is generally a correct option for logging
(I think the default is stderr)
stdout is essentially never the correct option for logging
it is for process output, not readable diagnostics. prefer std.log
okay thanks a lot
i wish you good luck!!! Welcome to zig!!! ping my anytime
also, std.log.info appends a \n and prepends info:
so i dont need to use \n?
indeed
correct
so its kinda similar to console.log then
yea its the closest method you can get pretty much
what would be the best way to accept text input from user in terminal?
you read from std.Io.File.stdin(), or you parse the command line arguments
I almost always parse the command line
okay that you so much
np
honestly: refer to posix for what the rest of the world thinks https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
in practice: make your own decisions but posix makes people happy and is kind of the expected default
(if you are writing a utility, if its something like a quiz app for learning programming or anything else interactive stdin is the way)
Im just learning. But what you sent isn’t it for command line arguments? I was thinking more like making a calculator to learn zig basics. Like enter first number, enter second, enter operation. This is my first day learning lmao.
then yeah stdin
see my last paragraph
I’ll try to follow standards because I also like standards thank you
if you are making a small interactive thing for learning then stdin
Hot take. Im going to disagree and say stderr is for error log messages, and stdout is for non error log messages.
falls apart the moment you make a tool that processes files (like cat)
also makes user unable to redirect logs all at once