OmniSciDB  addbbd5075
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logger::Logger Class Reference

#include <Logger.h>

Public Member Functions

 Logger (Channel)
 
 Logger (Severity)
 
 Logger (Logger &&)=default
 
 ~Logger ()
 
 operator bool () const
 
boost::log::record_ostream & stream (char const *file, int line)
 

Private Attributes

bool const is_channel_
 
int const enum_value_
 
std::unique_ptr
< boost::log::record > 
record_
 
std::unique_ptr
< boost::log::record_ostream > 
stream_
 

Detailed Description

Definition at line 157 of file Logger.h.

Constructor & Destructor Documentation

logger::Logger::Logger ( Channel  channel)

Definition at line 356 of file Logger.cpp.

References record_, and stream_.

357  : is_channel_(true)
358  , enum_value_(channel)
359  , record_(std::make_unique<boost::log::record>(
360  gChannelLogger::get().open_record(boost::log::keywords::channel = channel))) {
361  if (*record_) {
362  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
363  }
364 }
int const enum_value_
Definition: Logger.h:159
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:161
bool const is_channel_
Definition: Logger.h:158
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162
logger::Logger::Logger ( Severity  severity)

Definition at line 366 of file Logger.cpp.

References record_, and stream_.

367  : is_channel_(false)
368  , enum_value_(severity)
369  , record_(std::make_unique<boost::log::record>(gSeverityLogger::get().open_record(
370  boost::log::keywords::severity = severity))) {
371  if (*record_) {
372  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
373  }
374 }
int const enum_value_
Definition: Logger.h:159
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:161
bool const is_channel_
Definition: Logger.h:158
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162
logger::Logger::Logger ( Logger &&  )
default
logger::Logger::~Logger ( )

Definition at line 376 of file Logger.cpp.

References enum_value_, logger::FATAL, logger::g_fatal_func, logger::g_fatal_func_flag, is_channel_, and stream_.

376  {
377  if (stream_) {
378  if (is_channel_) {
379  gChannelLogger::get().push_record(boost::move(stream_->get_record()));
380  } else {
381  gSeverityLogger::get().push_record(boost::move(stream_->get_record()));
382  }
383  }
384  if (!is_channel_ && static_cast<Severity>(enum_value_) == Severity::FATAL) {
385  if (FatalFunc fatal_func = g_fatal_func.load()) {
386  // set_once_fatal_func() prevents race condition.
387  // Exceptions thrown by (*fatal_func)() are propagated here.
388  std::call_once(g_fatal_func_flag, *fatal_func);
389  }
390  abort();
391  }
392 }
int const enum_value_
Definition: Logger.h:159
std::once_flag g_fatal_func_flag
Definition: Logger.cpp:252
bool const is_channel_
Definition: Logger.h:158
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:251
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162
void(*)( FatalFunc)
Definition: Logger.h:147

Member Function Documentation

logger::Logger::operator bool ( ) const

Definition at line 394 of file Logger.cpp.

394  {
395  return static_cast<bool>(stream_);
396 }
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162
boost::log::record_ostream & logger::Logger::stream ( char const *  file,
int  line 
)

Definition at line 398 of file Logger.cpp.

References logger::filename(), and stream_.

398  {
399  return *stream_ << filename(file) << ':' << line << ' ';
400 }
std::string filename(char const *path)
Definition: Logger.cpp:58
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162

+ Here is the call graph for this function:

Member Data Documentation

int const logger::Logger::enum_value_
private

Definition at line 159 of file Logger.h.

Referenced by ~Logger().

bool const logger::Logger::is_channel_
private

Definition at line 158 of file Logger.h.

Referenced by ~Logger().

std::unique_ptr<boost::log::record> logger::Logger::record_
private

Definition at line 161 of file Logger.h.

Referenced by Logger().

std::unique_ptr<boost::log::record_ostream> logger::Logger::stream_
private

Definition at line 162 of file Logger.h.

Referenced by Logger(), stream(), and ~Logger().


The documentation for this class was generated from the following files: