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 <core/threading/thread.h>
27 #include <aspect/logging.h>
28 #include <aspect/logger.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <plugins/mongodb/aspect/mongodb.h>
32 
33 #include <string>
34 
35 namespace fawkes {
36  class Mutex;
37 }
38 
40 : public fawkes::Thread,
41  public fawkes::LoggingAspect,
42  public fawkes::LoggerAspect,
44  public fawkes::ClockAspect,
45  public fawkes::MongoDBAspect,
46  public fawkes::Logger
47 {
48  public:
50  virtual ~MongoLogLoggerThread();
51 
52  virtual void init();
53  virtual void loop();
54  virtual void finalize();
55 
56  virtual void log_debug(const char *component, const char *format, ...);
57  virtual void log_info(const char *component, const char *format, ...);
58  virtual void log_warn(const char *component, const char *format, ...);
59  virtual void log_error(const char *component, const char *format, ...);
60 
61  virtual void vlog_debug(const char *component, const char *format, va_list va);
62  virtual void vlog_info(const char *component, const char *format, va_list va);
63  virtual void vlog_warn(const char *component, const char *format, va_list va);
64  virtual void vlog_error(const char *component, const char *format, va_list va);
65 
66  virtual void log_debug(const char *component, fawkes::Exception &e);
67  virtual void log_info(const char *component, fawkes::Exception &e);
68  virtual void log_warn(const char *component, fawkes::Exception &e);
69  virtual void log_error(const char *component, fawkes::Exception &e);
70 
71  virtual void tlog_debug(struct timeval *t, const char *component,
72  const char *format, ...);
73  virtual void tlog_info(struct timeval *t, const char *component,
74  const char *format, ...);
75  virtual void tlog_warn(struct timeval *t, const char *component,
76  const char *format, ...);
77  virtual void tlog_error(struct timeval *t, const char *component,
78  const char *format, ...);
79 
80  virtual void tlog_debug(struct timeval *t, const char *component,
82  virtual void tlog_info(struct timeval *t, const char *component,
84  virtual void tlog_warn(struct timeval *t, const char *component,
86  virtual void tlog_error(struct timeval *t, const char *component,
88 
89  virtual void vtlog_debug(struct timeval *t, const char *component,
90  const char *format, va_list va);
91  virtual void vtlog_info(struct timeval *t, const char *component,
92  const char *format, va_list va);
93  virtual void vtlog_warn(struct timeval *t, const char *component,
94  const char *format, va_list va);
95  virtual void vtlog_error(struct timeval *t, const char *component,
96  const char *format, va_list va);
97 
98  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
99  protected: virtual void run() { Thread::run(); }
100 
101  private:
102  void insert_message(LogLevel ll, const char *component, const char *format,
103  va_list va);
104  void insert_message(LogLevel ll, const char *component, fawkes::Exception &e);
105  void tlog_insert_message(LogLevel ll, struct timeval *t, const char *component,
106  const char *format, va_list va);
107  void tlog_insert_message(LogLevel ll, struct timeval *t, const char *component,
109 
110  private:
111  std::string __collection;
112  fawkes::Mutex *__mutex;
113 };
114 
115 #endif
LogLevel
Log level.
Definition: logger.h:45
Thread aspect that allows to provide a logger to Fawkes.
Definition: logger.h:36
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Thread that provides a logger writing to MongoDB.
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Base class for exceptions in Fawkes.
Definition: exception.h:36
Thread aspect to access MongoDB.
Definition: mongodb.h:40
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Mutex mutual exclusion lock.
Definition: mutex.h:32
Interface for logging.
Definition: logger.h:34