2019-06-26 02:14:38 +02:00
|
|
|
import log
|
|
|
|
|
2019-11-25 05:50:59 +01:00
|
|
|
fn main() {
|
2019-12-01 10:50:13 +01:00
|
|
|
mut l := log.Log{}
|
2020-04-06 17:22:53 +02:00
|
|
|
l.set_level(.info)
|
2019-12-01 10:50:13 +01:00
|
|
|
// Make a new file called info.log in the current folder
|
|
|
|
l.set_full_logpath('./info.log')
|
2021-04-02 09:12:52 +02:00
|
|
|
l.log_to_console_too()
|
2021-02-23 18:43:44 +01:00
|
|
|
println('Please check the file: $l.output_file_name after this example crashes.')
|
2020-04-06 17:22:53 +02:00
|
|
|
|
2019-11-25 05:50:59 +01:00
|
|
|
l.info('info')
|
|
|
|
l.warn('warn')
|
|
|
|
l.error('error')
|
2021-12-18 11:38:43 +01:00
|
|
|
l.debug('no output for debug')
|
2020-04-06 17:22:53 +02:00
|
|
|
l.set_level(.debug)
|
2021-12-18 11:38:43 +01:00
|
|
|
l.debug('debug now')
|
|
|
|
l.set_level(log.level_from_tag('INFO') or { log.Level.disabled }) // set level from string, sample
|
|
|
|
l.info('info again')
|
|
|
|
l.set_level(log.level_from_tag('') or { log.Level.disabled }) // set level from string, sample
|
|
|
|
l.error('no output anymore')
|
|
|
|
l.fatal('fatal') // panic, next statements won't be executed
|
|
|
|
l.set_level(.info)
|
|
|
|
l.warn('warn')
|
2019-06-27 12:27:46 +02:00
|
|
|
}
|