2006-02-17 13:35:04 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
2006-09-21 15:31:24 +00:00
|
|
|
* aria2 - The high speed download utility
|
2006-02-17 13:35:04 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-09-21 15:31:24 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
2006-02-17 13:35:04 +00:00
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#ifndef _D_SIMPLE_LOGGER_H_
|
|
|
|
#define _D_SIMPLE_LOGGER_H_
|
|
|
|
|
|
|
|
#include "Logger.h"
|
2008-04-13 13:38:25 +00:00
|
|
|
#include <cstdarg>
|
2008-02-08 15:53:45 +00:00
|
|
|
#include <string>
|
2008-04-26 05:58:49 +00:00
|
|
|
#include <fstream>
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2006-02-17 13:35:04 +00:00
|
|
|
|
|
|
|
class SimpleLogger:public Logger {
|
|
|
|
private:
|
2008-04-27 02:22:14 +00:00
|
|
|
void writeFile(Logger::LEVEL level, const char* msg, va_list ap);
|
|
|
|
|
|
|
|
void writeStackTrace(Logger::LEVEL level, const Exception& e);
|
|
|
|
|
|
|
|
void flush();
|
|
|
|
|
2008-04-26 05:58:49 +00:00
|
|
|
void writeHeader(std::ostream& out,
|
|
|
|
const std::string& date, const std::string& level);
|
2008-04-27 02:22:14 +00:00
|
|
|
|
2008-04-26 05:58:49 +00:00
|
|
|
void writeLog(std::ostream& out, Logger::LEVEL level,
|
2008-02-08 15:53:45 +00:00
|
|
|
const char* msg, va_list ap,
|
2008-04-27 02:22:14 +00:00
|
|
|
bool printHeader = true);
|
2008-04-26 05:58:49 +00:00
|
|
|
|
|
|
|
std::ofstream file;
|
2008-03-09 12:24:01 +00:00
|
|
|
int stdoutField;
|
2008-05-13 16:28:31 +00:00
|
|
|
|
2008-05-15 15:48:41 +00:00
|
|
|
Logger::LEVEL _logLevel;
|
|
|
|
|
2008-05-13 16:28:31 +00:00
|
|
|
static const std::string DEBUG;
|
|
|
|
|
|
|
|
static const std::string NOTICE;
|
|
|
|
|
|
|
|
static const std::string WARN;
|
|
|
|
|
|
|
|
static const std::string ERROR;
|
|
|
|
|
|
|
|
static const std::string INFO;
|
2006-02-17 13:35:04 +00:00
|
|
|
public:
|
2008-04-26 05:58:49 +00:00
|
|
|
SimpleLogger();
|
2006-02-17 13:35:04 +00:00
|
|
|
~SimpleLogger();
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void openFile(const std::string& filename);
|
2006-04-19 17:23:58 +00:00
|
|
|
void closeFile();
|
2008-04-26 05:58:49 +00:00
|
|
|
virtual void debug(const char* msg, ...);
|
2008-05-10 05:16:16 +00:00
|
|
|
virtual void debug(const char* msg, const Exception& ex, ...);
|
2008-04-26 05:58:49 +00:00
|
|
|
virtual void info(const char* msg, ...);
|
2008-05-10 05:16:16 +00:00
|
|
|
virtual void info(const char* msg, const Exception& ex, ...);
|
2008-04-26 05:58:49 +00:00
|
|
|
virtual void notice(const char* msg, ...);
|
2008-05-10 05:16:16 +00:00
|
|
|
virtual void notice(const char* msg, const Exception& ex, ...);
|
2008-04-26 05:58:49 +00:00
|
|
|
virtual void warn(const char* msg, ...);
|
2008-05-10 05:16:16 +00:00
|
|
|
virtual void warn(const char* msg, const Exception& ex, ...);
|
2008-04-26 05:58:49 +00:00
|
|
|
virtual void error(const char* msg, ...);
|
2008-05-10 05:16:16 +00:00
|
|
|
virtual void error(const char* msg, const Exception& ex, ...);
|
2006-08-27 12:49:17 +00:00
|
|
|
|
2008-05-15 15:48:41 +00:00
|
|
|
virtual void setLogLevel(Logger::LEVEL level);
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
void setStdout(Logger::LEVEL level, bool enabled);
|
2006-02-17 13:35:04 +00:00
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
#endif // _D_SIMPLE_LOGGER_H_
|
|
|
|
|