2 * Copyright (C) 2009 Patrick Ohly <patrick.ohly@gmx.de>
3 * Copyright (C) 2009 Intel Corporation
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) version 3.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <syncevo/Logging.h>
22 #include <syncevo/LogStdout.h>
26 #include <syncevo/declarations.h>
29 static LoggerStdout DefaultLogger;
31 static std::vector<LoggerBase *> loggers;
32 LoggerBase &LoggerBase::instance()
34 if (!loggers.empty()) {
35 return *loggers[loggers.size() - 1];
41 void LoggerBase::pushLogger(LoggerBase *logger)
43 loggers.push_back(logger);
46 void LoggerBase::popLogger()
48 if (loggers.empty()) {
49 throw "too many popLogger() calls";
55 void Logger::message(Level level,
64 va_start(args, format);
65 messagev(level, prefix, file, line, function, format, args);
69 const char *Logger::levelToStr(Level level)
72 case ERROR: return "ERROR";
73 case WARNING: return "WARNING";
74 case INFO: return "INFO";
75 case DEV: return "DEVELOPER";
76 case DEBUG: return "DEBUG";
77 default: return "???";