mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
log: add log.use_stdout()
, use it to silence the transition note for the most commonly used V tools/examples (#23642)
This commit is contained in:
parent
23c3af8b4d
commit
319eb83525
12 changed files with 24 additions and 7 deletions
|
@ -58,16 +58,17 @@ fn main() {
|
|||
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():
|
||||
If you want to restore the previous behaviour, you have to explicitly call `log.use_stdout()` :
|
||||
```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.use_stdout()
|
||||
log.info('this will be printed to stdout')
|
||||
}
|
||||
```
|
||||
|
||||
If you want to just silence the note about the stdout -> stderr, during the transition period,
|
||||
call `l.set_output_stream(os.stderr())` explicitly.
|
||||
|
|
|
@ -324,3 +324,11 @@ pub fn (mut l Log) set_short_tag(enabled bool) {
|
|||
pub fn (l Log) get_short_tag() bool {
|
||||
return l.short_tag
|
||||
}
|
||||
|
||||
// use_stdout will restore the old behaviour of logging to stdout, instead of stderr.
|
||||
// It will also silence the deprecation note in the transition period.
|
||||
pub fn use_stdout() {
|
||||
mut l := ThreadSafeLog{}
|
||||
l.set_output_stream(os.stdout())
|
||||
set_logger(l)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue