#difference between log.info and Io.File.stdout().writeStreamingAll();

1 messages · Page 1 of 1 (latest)

long coyote
#

hi, im new to zig, i only know python but im trying to learn zig for fun. there are many hello world examples in documentations. what is the diffrence between the log example for zigzag and the hello world example using this try Io.File.stdout().writeStreamingAll(init.io, "hello world!\n"); }, std.log.info

dusk dirge
#

first one writes to stdout, second one may write to stderr, stdout, a log file, a log server, ...

fair galleon
dusk dirge
#

(I think the default is stderr)

fair galleon
#

stdout is essentially never the correct option for logging

#

it is for process output, not readable diagnostics. prefer std.log

long coyote
#

okay thanks a lot

urban cargo
#

i wish you good luck!!! Welcome to zig!!! ping my anytime

dusk dirge
#

also, std.log.info appends a \n and prepends info:

long coyote
urban cargo
#

indeed

dusk dirge
long coyote
#

so its kinda similar to console.log then

urban cargo
#

yea its the closest method you can get pretty much

long coyote
#

what would be the best way to accept text input from user in terminal?

dusk dirge
#

you read from std.Io.File.stdin(), or you parse the command line arguments

#

I almost always parse the command line

long coyote
#

okay that you so much

dusk dirge
#

np

molten delta
#

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)

long coyote
molten delta
#

see my last paragraph

long coyote
#

I’ll try to follow standards because I also like standards thank you

molten delta
#

if you are making a small interactive thing for learning then stdin

forest tide
fair galleon
#

also makes user unable to redirect logs all at once