vieter/src/web/logging.v

36 lines
845 B
Coq
Raw Normal View History

2022-01-11 14:01:13 +01:00
module web
import log
2022-01-14 22:46:04 +01:00
// log reate a log message with the given level
2022-11-01 21:10:45 +01:00
pub fn (mut ctx Context) log(msg string, level log.Level) {
2022-01-11 14:01:13 +01:00
lock ctx.logger {
ctx.logger.send_output(msg, level)
}
}
2022-01-14 22:46:04 +01:00
// lfatal create a log message with the fatal level
2022-11-01 21:10:45 +01:00
pub fn (mut ctx Context) lfatal(msg string) {
2022-01-11 14:01:13 +01:00
ctx.log(msg, log.Level.fatal)
}
2022-01-14 22:46:04 +01:00
// lerror create a log message with the error level
2022-11-01 21:10:45 +01:00
pub fn (mut ctx Context) lerror(msg string) {
2022-01-11 14:01:13 +01:00
ctx.log(msg, log.Level.error)
}
2022-01-14 22:46:04 +01:00
// lwarn create a log message with the warn level
2022-11-01 21:10:45 +01:00
pub fn (mut ctx Context) lwarn(msg string) {
2022-01-11 14:01:13 +01:00
ctx.log(msg, log.Level.warn)
}
2022-01-14 22:46:04 +01:00
// linfo create a log message with the info level
2022-11-01 21:10:45 +01:00
pub fn (mut ctx Context) linfo(msg string) {
2022-01-11 14:01:13 +01:00
ctx.log(msg, log.Level.info)
}
2022-01-14 22:46:04 +01:00
// ldebug create a log message with the debug level
2022-11-01 21:10:45 +01:00
pub fn (mut ctx Context) ldebug(msg string) {
2022-01-11 14:01:13 +01:00
ctx.log(msg, log.Level.debug)
}