Fawkes API  Fawkes Development Version
file.h
1 
2 /***************************************************************************
3  * file.h - Fawkes file logger
4  *
5  * Created: Tue Jan 16 16:47:03 2007
6  * Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
7  * 2007 Daniel Beck
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef _UTILS_LOGGING_FILE_H_
26 #define _UTILS_LOGGING_FILE_H_
27 
28 #include <logging/logger.h>
29 
30 #include <cstdio>
31 #include <ctime>
32 
33 namespace fawkes {
34 
35 class Mutex;
36 
37 class FileLogger : public Logger
38 {
39 public:
40  FileLogger(const char *filename, LogLevel min_level = LL_DEBUG);
41  virtual ~FileLogger();
42 
43  virtual void log_debug(const char *component, const char *format, ...);
44  virtual void log_info(const char *component, const char *format, ...);
45  virtual void log_warn(const char *component, const char *format, ...);
46  virtual void log_error(const char *component, const char *format, ...);
47 
48  virtual void vlog_debug(const char *component, const char *format, va_list va);
49  virtual void vlog_info(const char *component, const char *format, va_list va);
50  virtual void vlog_warn(const char *component, const char *format, va_list va);
51  virtual void vlog_error(const char *component, const char *format, va_list va);
52 
53  virtual void log_debug(const char *component, Exception &e);
54  virtual void log_info(const char *component, Exception &e);
55  virtual void log_warn(const char *component, Exception &e);
56  virtual void log_error(const char *component, Exception &e);
57 
58  virtual void tlog_debug(struct timeval *t, const char *component, const char *format, ...);
59  virtual void tlog_info(struct timeval *t, const char *component, const char *format, ...);
60  virtual void tlog_warn(struct timeval *t, const char *component, const char *format, ...);
61  virtual void tlog_error(struct timeval *t, const char *component, const char *format, ...);
62 
63  virtual void tlog_debug(struct timeval *t, const char *component, Exception &e);
64  virtual void tlog_info(struct timeval *t, const char *component, Exception &e);
65  virtual void tlog_warn(struct timeval *t, const char *component, Exception &e);
66  virtual void tlog_error(struct timeval *t, const char *component, Exception &e);
67 
68  virtual void
69  vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va);
70  virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va);
71  virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va);
72  virtual void
73  vtlog_error(struct timeval *t, const char *component, const char *format, va_list va);
74 
75 private:
76  struct ::tm *now_s;
77 
78  FILE * log_file;
79  Mutex *mutex;
80 };
81 
82 } // end namespace fawkes
83 
84 #endif
fawkes::FileLogger::log_info
virtual void log_info(const char *component, const char *format,...)
Definition: file.cpp:144
fawkes::FileLogger::~FileLogger
virtual ~FileLogger()
Destructor.
Definition: file.cpp:127
fawkes::FileLogger::vtlog_error
virtual void vtlog_error(struct timeval *t, const char *component, const char *format, va_list va)
Definition: file.cpp:554
fawkes::FileLogger::log_debug
virtual void log_debug(const char *component, const char *format,...)
Definition: file.cpp:135
fawkes::FileLogger::vtlog_debug
virtual void vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va)
Definition: file.cpp:491
fawkes::Mutex
Definition: mutex.h:38
fawkes::FileLogger::tlog_debug
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Definition: file.cpp:363
fawkes::FileLogger::FileLogger
FileLogger(const char *filename, LogLevel min_level=LL_DEBUG)
Constructor.
Definition: file.cpp:62
fawkes::FileLogger::log_error
virtual void log_error(const char *component, const char *format,...)
Definition: file.cpp:162
fawkes::FileLogger::log_warn
virtual void log_warn(const char *component, const char *format,...)
Definition: file.cpp:153
fawkes::FileLogger::tlog_info
virtual void tlog_info(struct timeval *t, const char *component, const char *format,...)
Definition: file.cpp:372
fawkes::FileLogger::vlog_warn
virtual void vlog_warn(const char *component, const char *format, va_list va)
Definition: file.cpp:317
fawkes::Logger::LL_DEBUG
@ LL_DEBUG
debug output, relevant only when tracking down problems
Definition: logger.h:52
fawkes::FileLogger::vlog_error
virtual void vlog_error(const char *component, const char *format, va_list va)
Definition: file.cpp:340
fawkes::FileLogger::vlog_debug
virtual void vlog_debug(const char *component, const char *format, va_list va)
Definition: file.cpp:271
fawkes::FileLogger::vlog_info
virtual void vlog_info(const char *component, const char *format, va_list va)
Definition: file.cpp:294
fawkes
fawkes::FileLogger::vtlog_warn
virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va)
Definition: file.cpp:533
fawkes::Logger::LogLevel
LogLevel
Log level.
Definition: logger.h:51
fawkes::FileLogger::tlog_error
virtual void tlog_error(struct timeval *t, const char *component, const char *format,...)
Definition: file.cpp:390
fawkes::FileLogger::tlog_warn
virtual void tlog_warn(struct timeval *t, const char *component, const char *format,...)
Definition: file.cpp:381
fawkes::FileLogger::vtlog_info
virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va)
Definition: file.cpp:512
fawkes::Exception
Definition: exception.h:41