Logo
Reference manual - version ored_version
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 <ql/any.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/lock_types.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  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)
 Logging Macro (Level = Alert).
#define CLOG(text)
 Logging Macro (Level = Critical).
#define ELOG(text)
 Logging Macro (Level = Error).
#define WLOG(text)
 Logging Macro (Level = Warning).
#define LOG(text)
 Logging Macro (Level = Notice).
#define DLOG(text)
 Logging Macro (Level = Debug).
#define TLOG(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, MSG)
#define CHECKED_LOGGERSTREAM(LEVEL, text)
#define ALOGGERSTREAM(text)
#define CLOGGERSTREAM(text)
#define ELOGGERSTREAM(text)
#define WLOGGERSTREAM(text)
#define LOGGERSTREAM(text)
#define DLOGGERSTREAM(text)
#define TLOGGERSTREAM(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.
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Category &)
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Group &)

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())) { \
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); \
} \
} \
}

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

◆ ALOG

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

Logging Macro (Level = Alert).

◆ CLOG

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

Logging Macro (Level = Critical).

◆ ELOG

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

Logging Macro (Level = Error).

◆ WLOG

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

Logging Macro (Level = Warning).

◆ LOG

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

Logging Macro (Level = Notice).

◆ DLOG

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

Logging Macro (Level = Debug).

◆ TLOG

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

Logging Macro (Level = Data).

◆ MEM_LOG_USING_LEVEL

#define MEM_LOG_USING_LEVEL ( LEVEL,
MSG )
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() << MSG << ": "; \
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().logStream() << " (peakMemoryUsage (bytes) | memoryUsage (bytes))"; \
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; \
}

◆ ALOGGERSTREAM

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

◆ CLOGGERSTREAM

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

◆ ELOGGERSTREAM

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

◆ WLOGGERSTREAM

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

◆ LOGGERSTREAM

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

◆ DLOGGERSTREAM

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

◆ TLOGGERSTREAM

#define TLOGGERSTREAM ( text)
Value:
CHECKED_LOGGERSTREAM(ORE_DATA, 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, ' '); \
boost::unique_lock<boost::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; \
boost::unique_lock<boost::shared_mutex> lock(ore::data::ConsoleLog::instance().mutex()); \
std::cout << oss.str() << "\n"; \
std::cout << std::flush; \
} \
}