From 5c89c0ec736770c94f97ced8a754c467d8536a09 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 28 Feb 2016 18:41:12 +0100 Subject: Minor Log.{h,cpp} improvements --- src/Log.cpp | 7 +++---- src/Log.h | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Log.cpp b/src/Log.cpp index 90548af..75380dd 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -68,10 +68,8 @@ void Logger::logstr(log_level_t level, std::string message) message.resize(message.length()-1); } - for (std::list::iterator it = backends.begin(); - it != backends.end(); - ++it) { - (*it)->log(level, message); + for (auto &backend : backends) { + backend->log(level, message); } { @@ -85,3 +83,4 @@ LogLine Logger::level(log_level_t level) { return LogLine(this, level); } + diff --git a/src/Log.h b/src/Log.h index 81490b2..2873818 100644 --- a/src/Log.h +++ b/src/Log.h @@ -52,7 +52,6 @@ static const std::string levels_as_str[] = /** Abstract class all backends must inherit from */ class LogBackend { public: - virtual ~LogBackend() {} virtual void log(log_level_t level, std::string message) = 0; virtual std::string get_name() = 0; }; @@ -116,7 +115,7 @@ class LogToFile : public LogBackend { {"DEBUG", "INFO", "WARN", "ERROR", "ALERT", "EMERG"}; // fprintf is thread-safe - fprintf(log_file, "ODR-DabMux: %s: %s\n", + fprintf(log_file, SYSLOG_IDENT ": %s: %s\n", log_level_text[(size_t)level], message.c_str()); fflush(log_file); } -- cgit v1.2.3