OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logging.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __LOGGING_H__
6 #define __LOGGING_H__
7 
8 #ifdef __clang__
9 #pragma clang diagnostic push
10 #pragma clang diagnostic ignored "-Wunused-variable"
11 #endif
12 
13 #include <log4cplus/logger.h>
14 #include <log4cplus/loggingmacros.h>
15 
16 #ifdef __clang__
17 #pragma clang diagnostic pop
18 #endif
19 
20 #ifdef __clang__
21 #pragma clang diagnostic push
22 #pragma clang diagnostic ignored "-Wmismatched-tags"
23 #endif
24 
25 #include <boost/units/detail/utility.hpp>
26 
27 #ifdef __clang__
28 #pragma clang diagnostic pop
29 #endif
30 
31 #define TYPE_NAME(_type) boost::units::detail::demangle(typeid(_type).name())
32 
33 #define LOG(_Level, _Msg) \
34  do { \
35  if (LoggingDisabled()) break; \
36  log4cplus::Logger logger = log4cplus::Logger::getRoot(); \
37  LOG4CPLUS_##_Level(logger, _Msg); \
38  } while (0)
39 
40 void LoggingInit();
41 void LoggingInit(const std::string &filename,
42  long maxFileSize,
43  int maxBackupIndex,
44  bool useSyslog,
45  const std::string &syslogFacility,
46  const std::string &ident,
47  log4cplus::LogLevel logLevel);
48 
49 void LoggingInit(const std::string &propertyFile);
50 void SetLoggingLevel(log4cplus::LogLevel logLevel);
51 bool LoggingUseSyslog();
52 
53 //
54 // Disable logging - For testing purposes only
55 //
56 bool LoggingDisabled();
57 void SetLoggingDisabled(bool flag);
58 void SetUseSysLog(bool); // To be used only for testing
59 #endif /* __LOGGING_H__ */
void LoggingInit()
Definition: logging.cc:51
bool LoggingUseSyslog()
Definition: logging.cc:32
void SetLoggingDisabled(bool flag)
Definition: logging.cc:28
bool LoggingDisabled()
Definition: logging.cc:24
void SetLoggingLevel(LogLevel logLevel)
Definition: logging.cc:46
void SetUseSysLog(bool use_syslog)
Definition: logging.cc:36