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 #include <cstdio>
30 #include <ctime>
31 
32 namespace fawkes {
33 
34 class Mutex;
35 
36 class FileLogger : public Logger
37 {
38  public:
39  FileLogger(const char* filename, LogLevel min_level = LL_DEBUG);
40  virtual ~FileLogger();
41 
42  virtual void log_debug(const char *component, const char *format, ...);
43  virtual void log_info(const char *component, const char *format, ...);
44  virtual void log_warn(const char *component, const char *format, ...);
45  virtual void log_error(const char *component, const char *format, ...);
46 
47  virtual void vlog_debug(const char *component, const char *format, va_list va);
48  virtual void vlog_info(const char *component, const char *format, va_list va);
49  virtual void vlog_warn(const char *component, const char *format, va_list va);
50  virtual void vlog_error(const char *component, const char *format, va_list va);
51 
52  virtual void log_debug(const char *component, Exception &e);
53  virtual void log_info(const char *component, Exception &e);
54  virtual void log_warn(const char *component, Exception &e);
55  virtual void log_error(const char *component, Exception &e);
56 
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 vtlog_debug(struct timeval *t, const char *component,
69  const char *format, va_list va);
70  virtual void vtlog_info(struct timeval *t, const char *component,
71  const char *format, va_list va);
72  virtual void vtlog_warn(struct timeval *t, const char *component,
73  const char *format, va_list va);
74  virtual void vtlog_error(struct timeval *t, const char *component,
75  const char *format, va_list va);
76 
77  private:
78  struct ::tm *now_s;
79 
80  FILE *log_file;
81  Mutex *mutex;
82 };
83 
84 
85 } // end namespace fawkes
86 
87 #endif
LogLevel
Log level.
Definition: logger.h:45
virtual void tlog_info(struct timeval *t, const char *component, const char *format,...)
Log informational message for specific time.
Definition: file.cpp:279
Interface for logging to a specified file.
Definition: file.h:36
Fawkes library namespace.
virtual void log_error(const char *component, const char *format,...)
Log error message.
Definition: file.cpp:107
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Log debug message for specific time.
Definition: file.cpp:269
FileLogger(const char *filename, LogLevel min_level=LL_DEBUG)
Constructor.
Definition: file.cpp:51
virtual void vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va)
Log debug message for specific time.
Definition: file.cpp:381
virtual void vlog_debug(const char *component, const char *format, va_list va)
Log debug message.
Definition: file.cpp:197
virtual void vlog_info(const char *component, const char *format, va_list va)
Log informational message.
Definition: file.cpp:215
virtual ~FileLogger()
Destructor.
Definition: file.cpp:68
Base class for exceptions in Fawkes.
Definition: exception.h:36
virtual void tlog_warn(struct timeval *t, const char *component, const char *format,...)
Log warning message for specific time.
Definition: file.cpp:289
virtual void vlog_warn(const char *component, const char *format, va_list va)
Log warning message.
Definition: file.cpp:233
virtual void tlog_error(struct timeval *t, const char *component, const char *format,...)
Log error message for specific time.
Definition: file.cpp:299
debug output, relevant only when tracking down problems
Definition: logger.h:46
virtual void log_warn(const char *component, const char *format,...)
Log warning message.
Definition: file.cpp:97
virtual void vlog_error(const char *component, const char *format, va_list va)
Log error message.
Definition: file.cpp:251
virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va)
Log informational message for specific time.
Definition: file.cpp:397
virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va)
Log warning message for specific time.
Definition: file.cpp:413
virtual void vtlog_error(struct timeval *t, const char *component, const char *format, va_list va)
Log error message for specific time.
Definition: file.cpp:429
Mutex mutual exclusion lock.
Definition: mutex.h:32
virtual void log_debug(const char *component, const char *format,...)
Log debug message.
Definition: file.cpp:77
virtual void log_info(const char *component, const char *format,...)
Log informational message.
Definition: file.cpp:87
Interface for logging.
Definition: logger.h:34