summaryrefslogtreecommitdiffstats
path: root/src/Log.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Log.h')
-rw-r--r--src/Log.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Log.h b/src/Log.h
index 607735c..e07e825 100644
--- a/src/Log.h
+++ b/src/Log.h
@@ -29,6 +29,7 @@
# include "config.h"
#endif
+#include <stdarg.h>
#include <stdio.h>
#include <syslog.h>
#include <fstream>
@@ -38,13 +39,9 @@
#include <stdexcept>
#include <string>
-#include "porting.h"
-
#define SYSLOG_IDENT "CRC-DABMUX"
#define SYSLOG_FACILITY LOG_LOCAL0
-extern Logger etiLog;
-
enum log_level_t {debug = 0, info, warn, error, alert, emerg};
/** Abstract class all backends must inherit from */
@@ -132,15 +129,20 @@ class Logger {
void register_backend(LogBackend* backend);
/* Log the message to all backends */
- void log(log_level_t level, std::string message);
+ void log(log_level_t level, const char* fmt, ...);
+
+ void logstr(log_level_t level, const std::string message);
- /* Return a LogLine for the given level */
+ /* Return a LogLine for the given level
+ * so that you can write etiLog.level(info) << "stuff = " << 21 */
LogLine level(log_level_t level);
private:
std::list<LogBackend*> backends;
};
+extern Logger etiLog;
+
// Accumulate a line of logs, using same syntax as stringstream
// The line is logged when the LogLine gets destroyed
class LogLine {
@@ -161,7 +163,7 @@ class LogLine {
~LogLine()
{
- logger_->log(level_, os.str());
+ logger_->logstr(level_, os.str());
}
private:
@@ -172,3 +174,4 @@ class LogLine {
#endif
+