OmniSciDB  95562058bd
 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 380 of file Logger.cpp.

References record_, and stream_.

381  : is_channel_(true)
382  , enum_value_(channel)
383  , record_(std::make_unique<boost::log::record>(
384  gChannelLogger::get().open_record(boost::log::keywords::channel = channel))) {
385  if (*record_) {
386  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
387  }
388 }
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 390 of file Logger.cpp.

References record_, and stream_.

391  : is_channel_(false)
392  , enum_value_(severity)
393  , record_(std::make_unique<boost::log::record>(gSeverityLogger::get().open_record(
394  boost::log::keywords::severity = severity))) {
395  if (*record_) {
396  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
397  }
398 }
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 400 of file Logger.cpp.

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

400  {
401  if (stream_) {
402  if (is_channel_) {
403  gChannelLogger::get().push_record(boost::move(stream_->get_record()));
404  } else {
405  gSeverityLogger::get().push_record(boost::move(stream_->get_record()));
406  }
407  }
408  if (!is_channel_ && static_cast<Severity>(enum_value_) == Severity::FATAL) {
409  if (FatalFunc fatal_func = g_fatal_func.load()) {
410  // set_once_fatal_func() prevents race condition.
411  // Exceptions thrown by (*fatal_func)() are propagated here.
412  std::call_once(g_fatal_func_flag, *fatal_func);
413  }
414  abort();
415  }
416 }
int const enum_value_
Definition: Logger.h:159
std::once_flag g_fatal_func_flag
Definition: Logger.cpp:260
void(*)() noexcept FatalFunc
Definition: Logger.h:147
bool const is_channel_
Definition: Logger.h:158
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:259
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162

Member Function Documentation

logger::Logger::operator bool ( ) const

Definition at line 418 of file Logger.cpp.

418  {
419  return static_cast<bool>(stream_);
420 }
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 422 of file Logger.cpp.

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

422  {
423  return *stream_ << thread_id() << ' ' << filename(file) << ':' << line << ' ';
424 }
std::string filename(char const *path)
Definition: Logger.cpp:62
tuple line
Definition: parse_ast.py:10
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:162
ThreadId thread_id()
Definition: Logger.cpp:731

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