Merge pull request 'Fix for configured log level being ignored.' (#339) from GreekStapler/vieter:fix/logging_level into dev
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/arch Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/push/man Pipeline was successful Details
ci/woodpecker/push/docker Pipeline was successful Details
ci/woodpecker/push/deploy Pipeline was successful Details

Reviewed-on: #339
pull/346/head
Jef Roosens 2023-01-08 09:27:12 +01:00
commit bfd28d6f70
3 changed files with 45 additions and 42 deletions

View File

@ -1,35 +1,36 @@
module agent module agent
import log
// log a message with the given level
pub fn (mut d AgentDaemon) log(msg string, level log.Level) {
lock d.logger {
d.logger.send_output(msg, level)
}
}
// lfatal create a log message with the fatal level // lfatal create a log message with the fatal level
pub fn (mut d AgentDaemon) lfatal(msg string) { pub fn (mut d AgentDaemon) lfatal(msg string) {
d.log(msg, log.Level.fatal) lock d.logger {
d.logger.fatal(msg)
}
} }
// lerror create a log message with the error level // lerror create a log message with the error level
pub fn (mut d AgentDaemon) lerror(msg string) { pub fn (mut d AgentDaemon) lerror(msg string) {
d.log(msg, log.Level.error) lock d.logger {
d.logger.error(msg)
}
} }
// lwarn create a log message with the warn level // lwarn create a log message with the warn level
pub fn (mut d AgentDaemon) lwarn(msg string) { pub fn (mut d AgentDaemon) lwarn(msg string) {
d.log(msg, log.Level.warn) lock d.logger {
d.logger.warn(msg)
}
} }
// linfo create a log message with the info level // linfo create a log message with the info level
pub fn (mut d AgentDaemon) linfo(msg string) { pub fn (mut d AgentDaemon) linfo(msg string) {
d.log(msg, log.Level.info) lock d.logger {
d.logger.info(msg)
}
} }
// ldebug create a log message with the debug level // ldebug create a log message with the debug level
pub fn (mut d AgentDaemon) ldebug(msg string) { pub fn (mut d AgentDaemon) ldebug(msg string) {
d.log(msg, log.Level.debug) lock d.logger {
d.logger.debug(msg)
}
} }

View File

@ -1,35 +1,36 @@
module daemon module daemon
import log
// log reate a log message with the given level
pub fn (mut d Daemon) log(msg string, level log.Level) {
lock d.logger {
d.logger.send_output(msg, level)
}
}
// lfatal create a log message with the fatal level // lfatal create a log message with the fatal level
pub fn (mut d Daemon) lfatal(msg string) { pub fn (mut d Daemon) lfatal(msg string) {
d.log(msg, log.Level.fatal) lock d.logger {
d.logger.fatal(msg)
}
} }
// lerror create a log message with the error level // lerror create a log message with the error level
pub fn (mut d Daemon) lerror(msg string) { pub fn (mut d Daemon) lerror(msg string) {
d.log(msg, log.Level.error) lock d.logger {
d.logger.error(msg)
}
} }
// lwarn create a log message with the warn level // lwarn create a log message with the warn level
pub fn (mut d Daemon) lwarn(msg string) { pub fn (mut d Daemon) lwarn(msg string) {
d.log(msg, log.Level.warn) lock d.logger {
d.logger.warn(msg)
}
} }
// linfo create a log message with the info level // linfo create a log message with the info level
pub fn (mut d Daemon) linfo(msg string) { pub fn (mut d Daemon) linfo(msg string) {
d.log(msg, log.Level.info) lock d.logger {
d.logger.info(msg)
}
} }
// ldebug create a log message with the debug level // ldebug create a log message with the debug level
pub fn (mut d Daemon) ldebug(msg string) { pub fn (mut d Daemon) ldebug(msg string) {
d.log(msg, log.Level.debug) lock d.logger {
d.logger.debug(msg)
}
} }

View File

@ -1,35 +1,36 @@
module web module web
import log
// log reate a log message with the given level
pub fn (mut ctx Context) log(msg string, level log.Level) {
lock ctx.logger {
ctx.logger.send_output(msg, level)
}
}
// lfatal create a log message with the fatal level // lfatal create a log message with the fatal level
pub fn (mut ctx Context) lfatal(msg string) { pub fn (mut ctx Context) lfatal(msg string) {
ctx.log(msg, log.Level.fatal) lock ctx.logger {
ctx.logger.fatal(msg)
}
} }
// lerror create a log message with the error level // lerror create a log message with the error level
pub fn (mut ctx Context) lerror(msg string) { pub fn (mut ctx Context) lerror(msg string) {
ctx.log(msg, log.Level.error) lock ctx.logger {
ctx.logger.error(msg)
}
} }
// lwarn create a log message with the warn level // lwarn create a log message with the warn level
pub fn (mut ctx Context) lwarn(msg string) { pub fn (mut ctx Context) lwarn(msg string) {
ctx.log(msg, log.Level.warn) lock ctx.logger {
ctx.logger.warn(msg)
}
} }
// linfo create a log message with the info level // linfo create a log message with the info level
pub fn (mut ctx Context) linfo(msg string) { pub fn (mut ctx Context) linfo(msg string) {
ctx.log(msg, log.Level.info) lock ctx.logger {
ctx.logger.info(msg)
}
} }
// ldebug create a log message with the debug level // ldebug create a log message with the debug level
pub fn (mut ctx Context) ldebug(msg string) { pub fn (mut ctx Context) ldebug(msg string) {
ctx.log(msg, log.Level.debug) lock ctx.logger {
ctx.logger.debug(msg)
}
} }