Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
log.hpp File Reference

Classes and functions for log message handling. More...

#include <fstream>
#include <iostream>
#include <string>
#include <time.h>
#include <boost/algorithm/string.hpp>
#include <boost/log/attributes/mutable_constant.hpp>
#include <boost/log/utility/manipulators/add_value.hpp>
#include <boost/log/attributes.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/expressions/formatters/date_time.hpp>
#include <boost/log/sinks.hpp>
#include <boost/log/sources/global_logger_storage.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/filesystem.hpp>
#include <ql/shared_ptr.hpp>
#include <map>
#include <ql/qldefines.hpp>
#include <queue>
#include <unistd.h>
#include <iomanip>
#include <ored/utilities/osutils.hpp>
#include <ql/patterns/singleton.hpp>
#include <sstream>
#include <boost/any.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/lock_types.hpp>

Go to the source code of this file.

Classes

class  Logger
 The Base Custom Log Handler class. More...
 
class  StderrLogger
 Stderr Logger. More...
 
class  FileLogger
 FileLogger. More...
 
class  BufferLogger
 BufferLogger. More...
 
class  IndependentLogger
 Base Log handler class that utilises Boost logging to create log sinks. More...
 
class  ProgressLogger
 
class  StructuredLogger
 
class  EventLogger
 EventLogger. More...
 
class  Log
 Global static Log class. More...
 
class  LoggerStream
 LoggerStream class that is a std::ostream replacement that will log each line. More...
 
class  JSONMessage
 
class  StructuredMessage
 
class  StructuredLoggingErrorMessage
 
class  EventMessage
 
class  ProgressMessage
 
class  ConsoleLog
 Singleton to control console logging. More...
 

Namespaces

namespace  ore
 Serializable Credit Default Swap.
 
namespace  ore::data
 

Macros

#define ORE_ALERT   1
 
#define ORE_CRITICAL   2
 
#define ORE_ERROR   4
 
#define ORE_WARNING   8
 
#define ORE_NOTICE   16
 
#define ORE_DEBUG   32
 
#define ORE_DATA   64
 
#define ORE_MEMORY   128
 
#define MLOG(mask, text)
 
#define ALOG(text)   MLOG(oreSeverity::alert, text);
 Logging Macro (Level = Alert) More...
 
#define CLOG(text)   MLOG(oreSeverity::critical, text)
 Logging Macro (Level = Critical) More...
 
#define ELOG(text)   MLOG(oreSeverity::error, text)
 Logging Macro (Level = Error) More...
 
#define WLOG(text)   MLOG(oreSeverity::warning, text)
 Logging Macro (Level = Warning) More...
 
#define LOG(text)   MLOG(oreSeverity::notice, text)
 Logging Macro (Level = Notice) More...
 
#define DLOG(text)   MLOG(oreSeverity::debug, text)
 Logging Macro (Level = Debug) More...
 
#define TLOG(text)   MLOG(oreSeverity::data, text)
 Logging Macro (Level = Data) More...
 
#define MEM_LOG   MEM_LOG_USING_LEVEL(oreSeverity::memory)
 Logging macro specifically for logging memory usage. More...
 
#define MEM_LOG_USING_LEVEL(LEVEL)
 
#define CHECKED_LOGGERSTREAM(LEVEL, text)
 
#define ALOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_ALERT, text)
 
#define CLOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_CRITICAL, text)
 
#define ELOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_ERROR, text)
 
#define WLOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_WARNING, text)
 
#define LOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_NOTICE, text)
 
#define DLOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_DEBUG, text)
 
#define TLOGGERSTREAM(text)   CHECKED_LOGGERSTREAM(ORE_DATA, text)
 
#define CONSOLEW(text)
 
#define CONSOLE(text)
 

Typedefs

typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend > file_sink
 
typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_ostream_backend > text_sink
 

Enumerations

enum  oreSeverity {
  alert = 1 , critical = 2 , error = 4 , warning = 8 ,
  notice = 16 , debug = 32 , data = 64 , memory = 128
}
 

Functions

template<typename CharT , typename TraitsT >
std::basic_ostream< CharT, TraitsT > & operator<< (std::basic_ostream< CharT, TraitsT > &strm, oreSeverity lvl)
 Outputs stringized representation of the severity level to the stream. More...
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Category &category)
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Group &group)
 

Detailed Description

Classes and functions for log message handling.

Definition in file log.hpp.

Macro Definition Documentation

◆ ORE_ALERT

#define ORE_ALERT   1

Definition at line 27 of file log.hpp.

◆ ORE_CRITICAL

#define ORE_CRITICAL   2

Definition at line 28 of file log.hpp.

◆ ORE_ERROR

#define ORE_ERROR   4

Definition at line 29 of file log.hpp.

◆ ORE_WARNING

#define ORE_WARNING   8

Definition at line 30 of file log.hpp.

◆ ORE_NOTICE

#define ORE_NOTICE   16

Definition at line 31 of file log.hpp.

◆ ORE_DEBUG

#define ORE_DEBUG   32

Definition at line 32 of file log.hpp.

◆ ORE_DATA

#define ORE_DATA   64

Definition at line 33 of file log.hpp.

◆ ORE_MEMORY

#define ORE_MEMORY   128

Definition at line 34 of file log.hpp.

◆ MLOG

#define MLOG (   mask,
  text 
)
Value:
{ \
if (ore::data::Log::instance().enabled() && ore::data::Log::instance().filter(mask)) { \
std::ostringstream __ore_mlog_tmp_stringstream__; \
__ore_mlog_tmp_stringstream__ << text; \
if (!ore::data::Log::instance().checkExcludeFilters(__ore_mlog_tmp_stringstream__.str())) { \
boost::unique_lock<boost::shared_mutex> lock(ore::data::Log::instance().mutex()); \
ore::data::Log::instance().header(mask, __FILE__, __LINE__); \
ore::data::Log::instance().logStream() << __ore_mlog_tmp_stringstream__.str(); \
ore::data::Log::instance().log(mask); \
} \
} \
}
SafeStack< Filter > filter

Main Logging macro, do not use this directly, use on of the below 6 macros instead

Definition at line 529 of file log.hpp.

◆ ALOG

#define ALOG (   text)    MLOG(oreSeverity::alert, text);

Logging Macro (Level = Alert)

Definition at line 544 of file log.hpp.

◆ CLOG

#define CLOG (   text)    MLOG(oreSeverity::critical, text)

Logging Macro (Level = Critical)

Definition at line 546 of file log.hpp.

◆ ELOG

#define ELOG (   text)    MLOG(oreSeverity::error, text)

Logging Macro (Level = Error)

Definition at line 548 of file log.hpp.

◆ WLOG

#define WLOG (   text)    MLOG(oreSeverity::warning, text)

Logging Macro (Level = Warning)

Definition at line 550 of file log.hpp.

◆ LOG

#define LOG (   text)    MLOG(oreSeverity::notice, text)

Logging Macro (Level = Notice)

Definition at line 552 of file log.hpp.

◆ DLOG

#define DLOG (   text)    MLOG(oreSeverity::debug, text)

Logging Macro (Level = Debug)

Definition at line 554 of file log.hpp.

◆ TLOG

#define TLOG (   text)    MLOG(oreSeverity::data, text)

Logging Macro (Level = Data)

Definition at line 556 of file log.hpp.

◆ MEM_LOG

Logging macro specifically for logging memory usage.

Definition at line 559 of file log.hpp.

◆ MEM_LOG_USING_LEVEL

#define MEM_LOG_USING_LEVEL (   LEVEL)
Value:
{ \
if (ore::data::Log::instance().enabled() && ore::data::Log::instance().filter(LEVEL)) { \
boost::unique_lock<boost::shared_mutex> lock(ore::data::Log::instance().mutex()); \
ore::data::Log::instance().header(LEVEL, __FILE__, __LINE__); \
ore::data::Log::instance().logStream() << std::to_string(ore::data::os::getPeakMemoryUsageBytes()) << "|"; \
ore::data::Log::instance().logStream() << std::to_string(ore::data::os::getMemoryUsageBytes()); \
ore::data::Log::instance().log(LEVEL); \
} \
}
unsigned long long getPeakMemoryUsageBytes()
Returns the current process peak memory usage in bytes.
Definition: osutils.cpp:207
unsigned long long getMemoryUsageBytes()
Definition: osutils.cpp:337

Definition at line 561 of file log.hpp.

◆ CHECKED_LOGGERSTREAM

#define CHECKED_LOGGERSTREAM (   LEVEL,
  text 
)
Value:
if (ore::data::Log::instance().enabled() && ore::data::Log::instance().filter(LEVEL)) { \
(std::ostream&)ore::data::LoggerStream(LEVEL, __FILE__, __LINE__) << text; \
}
LoggerStream class that is a std::ostream replacement that will log each line.
Definition: log.hpp:605

Definition at line 622 of file log.hpp.

◆ ALOGGERSTREAM

#define ALOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_ALERT, text)

Definition at line 627 of file log.hpp.

◆ CLOGGERSTREAM

#define CLOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_CRITICAL, text)

Definition at line 628 of file log.hpp.

◆ ELOGGERSTREAM

#define ELOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_ERROR, text)

Definition at line 629 of file log.hpp.

◆ WLOGGERSTREAM

#define WLOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_WARNING, text)

Definition at line 630 of file log.hpp.

◆ LOGGERSTREAM

#define LOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_NOTICE, text)

Definition at line 631 of file log.hpp.

◆ DLOGGERSTREAM

#define DLOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_DEBUG, text)

Definition at line 632 of file log.hpp.

◆ TLOGGERSTREAM

#define TLOGGERSTREAM (   text)    CHECKED_LOGGERSTREAM(ORE_DATA, text)

Definition at line 633 of file log.hpp.

◆ CONSOLEW

#define CONSOLEW (   text)
Value:
{ \
if (ore::data::ConsoleLog::instance().enabled()) { \
Size w = ore::data::ConsoleLog::instance().width(); \
std::ostringstream oss; \
oss << text; \
Size len = oss.str().length(); \
Size wsLen = w > len ? w - len : 1; \
oss << std::string(wsLen, ' '); \
boost::unique_lock<boost::shared_mutex> lock(ore::data::ConsoleLog::instance().mutex()); \
std::cout << oss.str(); \
std::cout << std::flush; \
} \
}

Definition at line 790 of file log.hpp.

◆ CONSOLE

#define CONSOLE (   text)
Value:
{ \
if (ore::data::ConsoleLog::instance().enabled()) { \
std::ostringstream oss; \
oss << text; \
boost::unique_lock<boost::shared_mutex> lock(ore::data::ConsoleLog::instance().mutex()); \
std::cout << oss.str() << "\n"; \
std::cout << std::flush; \
} \
}

Definition at line 805 of file log.hpp.

Enumeration Type Documentation

◆ oreSeverity

Enumerator
alert 
critical 
error 
warning 
notice 
debug 
data 
memory 

Definition at line 70 of file log.hpp.

70 {
77 data = ORE_DATA,
79};
@ notice
Definition: log.hpp:75
@ debug
Definition: log.hpp:76
@ critical
Definition: log.hpp:72
@ data
Definition: log.hpp:77
@ warning
Definition: log.hpp:74
@ memory
Definition: log.hpp:78
@ error
Definition: log.hpp:73
@ alert
Definition: log.hpp:71
#define ORE_DEBUG
Definition: log.hpp:32
#define ORE_CRITICAL
Definition: log.hpp:28
#define ORE_MEMORY
Definition: log.hpp:34
#define ORE_DATA
Definition: log.hpp:33
#define ORE_NOTICE
Definition: log.hpp:31
#define ORE_ERROR
Definition: log.hpp:29
#define ORE_WARNING
Definition: log.hpp:30
#define ORE_ALERT
Definition: log.hpp:27

Function Documentation

◆ operator<<()

std::basic_ostream< CharT, TraitsT > & operator<< ( std::basic_ostream< CharT, TraitsT > &  strm,
oreSeverity  lvl 
)

Outputs stringized representation of the severity level to the stream.

Definition at line 1 of file log.hpp.

84 {
85 switch (lvl) {
87 strm << "ALERT";
88 break;
90 strm << "CRITICAL";
91 break;
93 strm << "ERROR";
94 break;
96 strm << "WARNING";
97 break;
99 strm << "NOTICE";
100 break;
102 strm << "DEBUG";
103 break;
105 strm << "DATA";
106 break;
108 strm << "MEMORY";
109 break;
110 default:
111 strm << "UNKNOWN";
112 }
113
114 return strm;
115}