Logo
Reference manual - version ored_version
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 <shared_mutex>
#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 <boost/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>

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  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

 ore
 Serializable Credit Default Swap.
 
 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)
 
#define CLOG(text)   MLOG(oreSeverity::critical, text)
 Logging Macro (Level = Critical)
 
#define ELOG(text)   MLOG(oreSeverity::error, text)
 Logging Macro (Level = Error)
 
#define WLOG(text)   MLOG(oreSeverity::warning, text)
 Logging Macro (Level = Warning)
 
#define LOG(text)   MLOG(oreSeverity::notice, text)
 Logging Macro (Level = Notice)
 
#define DLOG(text)   MLOG(oreSeverity::debug, text)
 Logging Macro (Level = Debug)
 
#define TLOG(text)   MLOG(oreSeverity::data, text)
 Logging Macro (Level = Data)
 
#define MEM_LOG   MEM_LOG_USING_LEVEL(oreSeverity::memory)
 Logging macro specifically for logging memory usage.
 
#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 > cout_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.
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Category &)
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Group &)
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage &sm)
 
std::ostream & operator<< (std::ostream &out, const EventMessage &em)
 
std::ostream & operator<< (std::ostream &out, const ProgressMessage &pm)
 

Detailed Description

Classes and functions for log message handling.

Macro Definition Documentation

◆ 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())) { \
std::unique_lock<std::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); \
} \
} \
}

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

◆ MEM_LOG_USING_LEVEL

#define MEM_LOG_USING_LEVEL (   LEVEL)
Value:
{ \
if (ore::data::Log::instance().enabled() && ore::data::Log::instance().filter(LEVEL)) { \
std::unique_lock<std::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); \
} \
}

◆ 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; \
}

◆ 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, ' '); \
std::unique_lock<std::shared_mutex> lock(ore::data::ConsoleLog::instance().mutex()); \
std::cout << oss.str(); \
std::cout << std::flush; \
} \
}

◆ CONSOLE

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