diff --git a/src/agent/log.v b/src/agent/log.v index fcd8373..cd59207 100644 --- a/src/agent/log.v +++ b/src/agent/log.v @@ -1,36 +1,35 @@ 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 pub fn (mut d AgentDaemon) lfatal(msg string) { - lock d.logger { - d.logger.fatal(msg) - } + d.log(msg, log.Level.fatal) } // lerror create a log message with the error level pub fn (mut d AgentDaemon) lerror(msg string) { - lock d.logger { - d.logger.error(msg) - } + d.log(msg, log.Level.error) } // lwarn create a log message with the warn level pub fn (mut d AgentDaemon) lwarn(msg string) { - lock d.logger { - d.logger.warn(msg) - } + d.log(msg, log.Level.warn) } // linfo create a log message with the info level pub fn (mut d AgentDaemon) linfo(msg string) { - lock d.logger { - d.logger.info(msg) - } + d.log(msg, log.Level.info) } // ldebug create a log message with the debug level pub fn (mut d AgentDaemon) ldebug(msg string) { - lock d.logger { - d.logger.debug(msg) - } + d.log(msg, log.Level.debug) } diff --git a/src/web/logging.v b/src/web/logging.v index 7ba649c..12b07d7 100644 --- a/src/web/logging.v +++ b/src/web/logging.v @@ -1,36 +1,35 @@ 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 pub fn (mut ctx Context) lfatal(msg string) { - lock ctx.logger { - ctx.logger.fatal(msg) - } + ctx.log(msg, log.Level.fatal) } // lerror create a log message with the error level pub fn (mut ctx Context) lerror(msg string) { - lock ctx.logger { - ctx.logger.error(msg) - } + ctx.log(msg, log.Level.error) } // lwarn create a log message with the warn level pub fn (mut ctx Context) lwarn(msg string) { - lock ctx.logger { - ctx.logger.warn(msg) - } + ctx.log(msg, log.Level.warn) } // linfo create a log message with the info level pub fn (mut ctx Context) linfo(msg string) { - lock ctx.logger { - ctx.logger.info(msg) - } + ctx.log(msg, log.Level.info) } // ldebug create a log message with the debug level pub fn (mut ctx Context) ldebug(msg string) { - lock ctx.logger { - ctx.logger.debug(msg) - } + ctx.log(msg, log.Level.debug) }