vieter/src/web/logging.v

36 lines
851 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-01-11 14:01:13 +01:00
pub fn (mut ctx Context) log(msg &string, level log.Level) {
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-01-11 14:01:13 +01:00
pub fn (mut ctx Context) lfatal(msg &string) {
ctx.log(msg, log.Level.fatal)
}
2022-01-14 22:46:04 +01:00
// lerror create a log message with the error level
2022-01-11 14:01:13 +01:00
pub fn (mut ctx Context) lerror(msg &string) {
ctx.log(msg, log.Level.error)
}
2022-01-14 22:46:04 +01:00
// lwarn create a log message with the warn level
2022-01-11 14:01:13 +01:00
pub fn (mut ctx Context) lwarn(msg &string) {
ctx.log(msg, log.Level.warn)
}
2022-01-14 22:46:04 +01:00
// linfo create a log message with the info level
2022-01-11 14:01:13 +01:00
pub fn (mut ctx Context) linfo(msg &string) {
ctx.log(msg, log.Level.info)
}
2022-01-14 22:46:04 +01:00
// ldebug create a log message with the debug level
2022-01-11 14:01:13 +01:00
pub fn (mut ctx Context) ldebug(msg &string) {
ctx.log(msg, log.Level.debug)
}