Fawkes API  Fawkes Development Version
mongodb_log_logger_thread.h
1 
2 /***************************************************************************
3  * mongodb_logger_thread.h - MongoDB logger thread
4  *
5  * Created: Tue Dec 07 22:54:59 2010
6  * Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_MONGODB_MONGODB_LOGGER_THREAD_H_
24 #define _PLUGINS_MONGODB_MONGODB_LOGGER_THREAD_H_
25 
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logger.h>
29 #include <aspect/logging.h>
30 #include <core/threading/thread.h>
31 #include <plugins/mongodb/aspect/mongodb.h>
32 
33 #include <string>
34 
35 namespace fawkes {
36 class Mutex;
37 }
38 
40  public fawkes::LoggingAspect,
41  public fawkes::LoggerAspect,
43  public fawkes::ClockAspect,
44  public fawkes::MongoDBAspect,
45  public fawkes::Logger
46 {
47 public:
49  virtual ~MongoLogLoggerThread();
50 
51  virtual void init();
52  virtual void loop();
53  virtual void finalize();
54 
55  virtual void log_debug(const char *component, const char *format, ...);
56  virtual void log_info(const char *component, const char *format, ...);
57  virtual void log_warn(const char *component, const char *format, ...);
58  virtual void log_error(const char *component, const char *format, ...);
59 
60  virtual void vlog_debug(const char *component, const char *format, va_list va);
61  virtual void vlog_info(const char *component, const char *format, va_list va);
62  virtual void vlog_warn(const char *component, const char *format, va_list va);
63  virtual void vlog_error(const char *component, const char *format, va_list va);
64 
65  virtual void log_debug(const char *component, fawkes::Exception &e);
66  virtual void log_info(const char *component, fawkes::Exception &e);
67  virtual void log_warn(const char *component, fawkes::Exception &e);
68  virtual void log_error(const char *component, fawkes::Exception &e);
69 
70  virtual void tlog_debug(struct timeval *t, const char *component, const char *format, ...);
71  virtual void tlog_info(struct timeval *t, const char *component, const char *format, ...);
72  virtual void tlog_warn(struct timeval *t, const char *component, const char *format, ...);
73  virtual void tlog_error(struct timeval *t, const char *component, const char *format, ...);
74 
75  virtual void tlog_debug(struct timeval *t, const char *component, fawkes::Exception &e);
76  virtual void tlog_info(struct timeval *t, const char *component, fawkes::Exception &e);
77  virtual void tlog_warn(struct timeval *t, const char *component, fawkes::Exception &e);
78  virtual void tlog_error(struct timeval *t, const char *component, fawkes::Exception &e);
79 
80  virtual void
81  vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va);
82  virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va);
83  virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va);
84  virtual void
85  vtlog_error(struct timeval *t, const char *component, const char *format, va_list va);
86 
87  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
88 protected:
89  virtual void
90  run()
91  {
92  Thread::run();
93  }
94 
95 private:
96  void insert_message(LogLevel ll, const char *component, const char *format, va_list va);
97  void insert_message(LogLevel ll, const char *component, fawkes::Exception &e);
98  void tlog_insert_message(LogLevel ll,
99  struct timeval *t,
100  const char * component,
101  const char * format,
102  va_list va);
103  void
104  tlog_insert_message(LogLevel ll, struct timeval *t, const char *component, fawkes::Exception &);
105 
106 private:
107  std::string collection_;
108  fawkes::Mutex *mutex_;
109 };
110 
111 #endif
LogLevel
Log level.
Definition: logger.h:51
virtual void vtlog_error(struct timeval *t, const char *component, const char *format, va_list va)
Log error message for specific time.
Thread aspect that allows to provide a logger to Fawkes.
Definition: logger.h:33
virtual void tlog_warn(struct timeval *t, const char *component, const char *format,...)
Log warning message for specific time.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:33
virtual void finalize()
Finalize the thread.
virtual void vlog_info(const char *component, const char *format, va_list va)
Log informational message.
Thread that provides a logger writing to MongoDB.
Fawkes library namespace.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread class encapsulation of pthreads.
Definition: thread.h:45
virtual void log_debug(const char *component, const char *format,...)
Log debug message.
virtual void log_error(const char *component, const char *format,...)
Log error message.
virtual void tlog_error(struct timeval *t, const char *component, const char *format,...)
Log error message for specific time.
virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va)
Log informational message for specific time.
Base class for exceptions in Fawkes.
Definition: exception.h:35
virtual ~MongoLogLoggerThread()
Destructor.
Thread aspect to access MongoDB.
Definition: mongodb.h:39
virtual void log_warn(const char *component, const char *format,...)
Log warning message.
virtual void log_info(const char *component, const char *format,...)
Log informational message.
virtual void loop()
Code to execute in the thread.
Thread aspect to log output.
Definition: logging.h:32
virtual void vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va)
Log debug message for specific time.
Thread aspect to access configuration data.
Definition: configurable.h:32
virtual void vlog_error(const char *component, const char *format, va_list va)
Log error message.
virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va)
Log warning message for specific time.
virtual void init()
Initialize the thread.
virtual void vlog_warn(const char *component, const char *format, va_list va)
Log warning message.
Mutex mutual exclusion lock.
Definition: mutex.h:32
virtual void tlog_info(struct timeval *t, const char *component, const char *format,...)
Log informational message for specific time.
virtual void vlog_debug(const char *component, const char *format, va_list va)
Log debug message.
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Log debug message for specific time.
Interface for logging.
Definition: logger.h:41