OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 246 of file Logger.h.

Constructor & Destructor Documentation

logger::Logger::Logger ( Channel  channel)
explicit

Definition at line 486 of file Logger.cpp.

References record_, and stream_.

487  : is_channel_(true)
488  , enum_value_(channel)
489  , record_(std::make_unique<boost::log::record>(
490  get_channel_logger(channel).open_record())) {
491  if (*record_) {
492  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
493  }
494 }
int const enum_value_
Definition: Logger.h:248
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:250
bool const is_channel_
Definition: Logger.h:247
ChannelLogger & get_channel_logger(Channel const channel)
Definition: Logger.cpp:473
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:251
logger::Logger::Logger ( Severity  severity)
explicit

Definition at line 496 of file Logger.cpp.

References record_, and stream_.

497  : is_channel_(false)
498  , enum_value_(severity)
499  , record_(std::make_unique<boost::log::record>(
500  gSeverityLogger::get().open_record(keywords::severity = severity))) {
501  if (*record_) {
502  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
503  }
504 }
int const enum_value_
Definition: Logger.h:248
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:250
bool const is_channel_
Definition: Logger.h:247
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:251
logger::Logger::Logger ( Logger &&  )
default
logger::Logger::~Logger ( )

Definition at line 506 of file Logger.cpp.

References enum_value_, logger::FATAL, logger::g_fatal_func, logger::g_fatal_func_flag, logger::anonymous_namespace{Logger.cpp}::get_channel_logger(), is_channel_, and stream_.

506  {
507  if (stream_) {
508  if (is_channel_) {
509  get_channel_logger(static_cast<Channel>(enum_value_))
510  .push_record(boost::move(stream_->get_record()));
511  } else {
512  gSeverityLogger::get().push_record(boost::move(stream_->get_record()));
513  }
514  }
515  if (!is_channel_ && static_cast<Severity>(enum_value_) == Severity::FATAL) {
516  if (FatalFunc fatal_func = g_fatal_func.load()) {
517  // set_once_fatal_func() prevents race condition.
518  // Exceptions thrown by (*fatal_func)() are propagated here.
519  std::call_once(g_fatal_func_flag, *fatal_func);
520  }
521  abort();
522  }
523 }
int const enum_value_
Definition: Logger.h:248
std::once_flag g_fatal_func_flag
Definition: Logger.cpp:338
void(*)() noexcept FatalFunc
Definition: Logger.h:242
bool const is_channel_
Definition: Logger.h:247
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:337
ChannelLogger & get_channel_logger(Channel const channel)
Definition: Logger.cpp:473
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:251

+ Here is the call graph for this function:

Member Function Documentation

logger::Logger::operator bool ( ) const

Definition at line 525 of file Logger.cpp.

525  {
526  return static_cast<bool>(stream_);
527 }
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:251
boost::log::record_ostream & logger::Logger::stream ( char const *  file,
int  line 
)

Definition at line 547 of file Logger.cpp.

References nvtx_helpers::anonymous_namespace{nvtx_helpers.cpp}::filename(), logger::anonymous_namespace{Logger.cpp}::g_thread_local_ids(), logger::ThreadLocalIds::request_id_, stream_, and logger::ThreadLocalIds::thread_id_.

547  {
548  return *stream_ << g_thread_local_ids.request_id_ << ' '
549  << g_thread_local_ids.thread_id_ << ' ' << filename(file) << ':' << line
550  << ' ';
551 }
RequestId request_id_
Definition: Logger.h:135
thread_local ThreadLocalIds g_thread_local_ids(0, 0)
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:251
tuple line
Definition: parse_ast.py:10
ThreadId thread_id_
Definition: Logger.h:136

+ Here is the call graph for this function:

Member Data Documentation

int const logger::Logger::enum_value_
private

Definition at line 248 of file Logger.h.

Referenced by ~Logger().

bool const logger::Logger::is_channel_
private

Definition at line 247 of file Logger.h.

Referenced by ~Logger().

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

Definition at line 250 of file Logger.h.

Referenced by Logger().

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

Definition at line 251 of file Logger.h.

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


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