log: improve the most common use case (#19242)

This commit is contained in:
Delyan Angelov 2023-08-31 06:44:11 +03:00 committed by GitHub
parent 55575fd7bd
commit 6fb4a481f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 576 additions and 150 deletions

View file

@ -1,6 +1,14 @@
import log
fn main() {
// Note: you *do not* need to create a logger instance, and pass it around, just to use the `log` module.
// The log module already creates an instance of a thread safe Logger, and utility functions to work with it:
log.set_level(.debug)
log.debug('simple debug message')
log.warn('simple warning message')
log.info('simple information message')
log.error('simple error message')
mut l := log.Log{}
l.set_level(.info)
// Make a new file called info.log in the current folder