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/LogStdout.h>
25 #include <syncevo/declarations.h>
29 LoggerStdout::LoggerStdout(FILE *file) :
34 LoggerStdout::LoggerStdout(const std::string &filename) :
35 m_file(fopen(filename.c_str(), "w")),
39 throw std::string(filename + ": " + strerror(errno));
43 LoggerStdout::~LoggerStdout()
50 void LoggerStdout::messagev(FILE *file,
61 msglevel <= filelevel) {
63 fprintf(file, "[%s] ", levelToStr(msglevel));
65 fprintf(file, "%s: ", prefix);
67 // TODO: print debugging information, perhaps only in log file
68 vfprintf(file, format, args);
69 // TODO: add newline only when needed, add prefix to all lines
75 void LoggerStdout::messagev(Level level,
83 messagev(m_file, level, getLevel(),
84 prefix, file, line, function,