mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
log: allow for -d log_default_level=debug
, to change the default log level for programs and tests, that do not explicitly call log.set_level/1 themselves.
This commit is contained in:
parent
f683ab69d6
commit
bb7f9f2562
@ -14,6 +14,7 @@ fn test_reopen() {
|
||||
|
||||
dump(lfolder)
|
||||
mut l := log.new_thread_safe_log()
|
||||
l.set_level(.debug)
|
||||
l.set_full_logpath(lpath1)
|
||||
l.warn('one warning')
|
||||
l.error('one error')
|
||||
@ -42,6 +43,7 @@ fn test_reopen() {
|
||||
}
|
||||
|
||||
fn test_set_always_flush() {
|
||||
log.set_level(.debug)
|
||||
lfolder := os.join_path(os.vtmp_dir(), rand.ulid())
|
||||
lpath1 := os.join_path(lfolder, 'current.log')
|
||||
os.mkdir_all(lfolder)!
|
||||
|
@ -13,8 +13,10 @@ pub mut:
|
||||
// new_thread_safe_log returns a new log structure, whose methods are safe
|
||||
// to call by multiple threads.
|
||||
pub fn new_thread_safe_log() &ThreadSafeLog {
|
||||
slevel := $d('log_default_level', 'info')
|
||||
level := level_from_tag(slevel.to_upper()) or { panic('invalid log_default_level: ${slevel}') }
|
||||
mut x := &ThreadSafeLog{
|
||||
level: .info
|
||||
level: level
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user