Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
logger.hh
Go to the documentation of this file.
1 // @file
2 // @author Vicente Adolfo Bolea Sanchez
3 // @brief Simple Logger interface
4 //
5 // @usage
6 // Logger* log;
7 // log = Logger::connect ("Eclipse", LOG_LOCAL7);
8 //
9 // log->info ("Message here %d %s", 1, "sdas");
10 // log->warn ("Message here %d %s", 1, "sdas");
11 // log->error ("Message here %d %s", 1, "sdas");
12 //
13 // Logger::disconnect(log);
14 //
15 #ifndef __LOGGER_HH__
16 #define __LOGGER_HH__
17 
18 #include <string>
19 
20 class Logger {
21  private:
22  void log (int, const char*, va_list);
23 
24  // Singleton things
25  static Logger* singleton;
26  Logger(char*, const std::string&, std::string mask_);
27  ~Logger();
28 
29  std::string title;
30  int type;
31 
32  public:
33  static Logger* connect(std::string, std::string, std::string);
34  static void disconnect(Logger*);
35 
36  void debug (const char* fmt, ...);
37  void info (const char* fmt, ...);
38  void notice (const char* fmt, ...);
39  void warn (const char* fmt, ...);
40  void error (const char* fmt, ...);
41  void panic (const char* fmt, ...);
42 
43  void panic_if (bool, const char* fmt, ...);
44  void error_if (bool, const char* fmt, ...);
45 };
46 
47 #endif
Definition: logger.hh:20
void warn(const char *fmt,...)
Definition: logger.cc:101
void debug(const char *fmt,...)
Definition: logger.cc:77
void info(const char *fmt,...)
Definition: logger.cc:85
void notice(const char *fmt,...)
Definition: logger.cc:93
static void disconnect(Logger *)
Definition: logger.cc:42
static Logger * connect(std::string, std::string, std::string)
Definition: logger.cc:31
void error(const char *fmt,...)
Definition: logger.cc:109
void panic_if(bool, const char *fmt,...)
Definition: logger.cc:130
void panic(const char *fmt,...)
Definition: logger.cc:121
void error_if(bool, const char *fmt,...)
Definition: logger.cc:141