From 0b36f44c7bf0d8fc0a230c9acdc480cbd3965e5e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 18 Sep 2016 16:55:37 +0200 Subject: Don't send trace logs to syslog --- src/Log.cpp | 25 ++++++++++++++++++++++++- src/Log.h | 23 +++++------------------ 2 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Log.cpp b/src/Log.cpp index 81f32a8..155fc00 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -3,7 +3,10 @@ Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C), 2016, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2016 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -124,6 +127,26 @@ void LogToFile::log(log_level_t level, std::string message) } } +void LogToSyslog::log(log_level_t level, std::string message) +{ + if (level != log_level_t::trace) { + int syslog_level = LOG_EMERG; + switch (level) { + case trace: break; // Do not handle TRACE in syslog + case debug: syslog_level = LOG_DEBUG; break; + case info: syslog_level = LOG_INFO; break; + /* we don't have the notice level */ + case warn: syslog_level = LOG_WARNING; break; + case error: syslog_level = LOG_ERR; break; + default: syslog_level = LOG_CRIT; break; + case alert: syslog_level = LOG_ALERT; break; + case emerg: syslog_level = LOG_EMERG; break; + } + + syslog(syslog_level, SYSLOG_IDENT " %s", message.c_str()); + } +} + LogTracer::LogTracer(const string& trace_filename) { name = "TRACE"; diff --git a/src/Log.h b/src/Log.h index 799ca85..d6cd651 100644 --- a/src/Log.h +++ b/src/Log.h @@ -3,7 +3,10 @@ Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C), 2016, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2016 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -70,23 +73,7 @@ class LogToSyslog : public LogBackend { closelog(); } - void log(log_level_t level, std::string message) { - - int syslog_level = LOG_EMERG; - switch (level) { - case trace: break; // Do not handle TRACE in syslog - case debug: syslog_level = LOG_DEBUG; break; - case info: syslog_level = LOG_INFO; break; - /* we don't have the notice level */ - case warn: syslog_level = LOG_WARNING; break; - case error: syslog_level = LOG_ERR; break; - default: syslog_level = LOG_CRIT; break; - case alert: syslog_level = LOG_ALERT; break; - case emerg: syslog_level = LOG_EMERG; break; - } - - syslog(syslog_level, SYSLOG_IDENT " %s", message.c_str()); - } + void log(log_level_t level, std::string message); std::string get_name() { return name; } -- cgit v1.2.3