OmniSciDB  b24e664e58
 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 154 of file Logger.h.

Constructor & Destructor Documentation

logger::Logger::Logger ( Channel  channel)

Definition at line 349 of file Logger.cpp.

References record_, and stream_.

350  : is_channel_(true)
351  , enum_value_(channel)
352  , record_(std::make_unique<boost::log::record>(
353  gChannelLogger::get().open_record(boost::log::keywords::channel = channel))) {
354  if (*record_) {
355  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
356  }
357 }
int const enum_value_
Definition: Logger.h:156
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:158
bool const is_channel_
Definition: Logger.h:155
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:159
logger::Logger::Logger ( Severity  severity)

Definition at line 359 of file Logger.cpp.

References record_, and stream_.

360  : is_channel_(false)
361  , enum_value_(severity)
362  , record_(std::make_unique<boost::log::record>(gSeverityLogger::get().open_record(
363  boost::log::keywords::severity = severity))) {
364  if (*record_) {
365  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
366  }
367 }
int const enum_value_
Definition: Logger.h:156
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:158
bool const is_channel_
Definition: Logger.h:155
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:159
logger::Logger::Logger ( Logger &&  )
default
logger::Logger::~Logger ( )

Definition at line 369 of file Logger.cpp.

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

369  {
370  if (stream_) {
371  if (is_channel_) {
372  gChannelLogger::get().push_record(boost::move(stream_->get_record()));
373  } else {
374  gSeverityLogger::get().push_record(boost::move(stream_->get_record()));
375  }
376  }
377  if (!is_channel_ && static_cast<Severity>(enum_value_) == Severity::FATAL) {
378  if (FatalFunc fatal_func = g_fatal_func.load()) {
379  // set_once_fatal_func() prevents race condition.
380  // Exceptions thrown by (*fatal_func)() are propagated here.
381  std::call_once(g_fatal_func_flag, *fatal_func);
382  }
383  abort();
384  }
385 }
int const enum_value_
Definition: Logger.h:156
std::once_flag g_fatal_func_flag
Definition: Logger.cpp:245
bool const is_channel_
Definition: Logger.h:155
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:244
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:159
void(*)( FatalFunc)
Definition: Logger.h:144

Member Function Documentation

logger::Logger::operator bool ( ) const

Definition at line 387 of file Logger.cpp.

387  {
388  return static_cast<bool>(stream_);
389 }
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:159
boost::log::record_ostream & logger::Logger::stream ( char const *  file,
int  line 
)

Definition at line 391 of file Logger.cpp.

References logger::filename(), and stream_.

391  {
392  return *stream_ << filename(file) << ':' << line << ' ';
393 }
std::string filename(char const *path)
Definition: Logger.cpp:58
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:159

+ Here is the call graph for this function:

Member Data Documentation

int const logger::Logger::enum_value_
private

Definition at line 156 of file Logger.h.

Referenced by ~Logger().

bool const logger::Logger::is_channel_
private

Definition at line 155 of file Logger.h.

Referenced by ~Logger().

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

Definition at line 158 of file Logger.h.

Referenced by Logger().

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

Definition at line 159 of file Logger.h.

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


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