Skip to content

Commit

Permalink
log: add an example of how to restore the old default behaviour of pr…
Browse files Browse the repository at this point in the history
…inting to stdout to the docs
  • Loading branch information
spytheman committed Jan 21, 2025
1 parent 8f4bd5f commit d8282fb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions vlib/log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,22 @@ fn main() {
l.fatal('fatal') // panic, marked as [noreturn]
}
```

## Backwards compatibility

After 2025/01/21, the `log` module outputs to `stderr` by default.
Before that, it used `stdout` by default.

If you want to restore the previous behaviour, you have to explicitly call l.set_output_stream():
```v
import os
import log
fn main() {
// log.info('this will be printed to stderr after 2025/01/21 by default')
mut l := log.ThreadSafeLog{}
l.set_output_stream(os.stdout())
log.set_logger(l)
log.info('this will be printed to stdout')
}
```

0 comments on commit d8282fb

Please sign in to comment.