OmniSciDB  06b3bd477c
 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 362 of file Logger.cpp.

References record_, and stream_.

363  : is_channel_(true)
364  , enum_value_(channel)
365  , record_(std::make_unique<boost::log::record>(
366  gChannelLogger::get().open_record(boost::log::keywords::channel = channel))) {
367  if (*record_) {
368  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
369  }
370 }
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 372 of file Logger.cpp.

References record_, and stream_.

373  : is_channel_(false)
374  , enum_value_(severity)
375  , record_(std::make_unique<boost::log::record>(gSeverityLogger::get().open_record(
376  boost::log::keywords::severity = severity))) {
377  if (*record_) {
378  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
379  }
380 }
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 382 of file Logger.cpp.

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

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

Member Function Documentation

logger::Logger::operator bool ( ) const

Definition at line 400 of file Logger.cpp.

400  {
401  return static_cast<bool>(stream_);
402 }
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 404 of file Logger.cpp.

References logger::filename(), stream_, and logger::thread_id().

404  {
405  return *stream_ << thread_id() << ' ' << filename(file) << ':' << line << ' ';
406 }
std::string filename(char const *path)
Definition: Logger.cpp:62
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162
ThreadId thread_id()
Definition: Logger.cpp:715

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