OmniSciDB  72c90bc290
 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 248 of file Logger.h.

Constructor & Destructor Documentation

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

Definition at line 492 of file Logger.cpp.

References record_, and stream_.

493  : is_channel_(true)
494  , enum_value_(channel)
495  , record_(std::make_unique<boost::log::record>(
496  get_channel_logger(channel).open_record())) {
497  if (*record_) {
498  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
499  }
500 }
int const enum_value_
Definition: Logger.h:250
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:252
bool const is_channel_
Definition: Logger.h:249
ChannelLogger & get_channel_logger(Channel const channel)
Definition: Logger.cpp:477
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:253
logger::Logger::Logger ( Severity  severity)
explicit

Definition at line 502 of file Logger.cpp.

References record_, and stream_.

503  : is_channel_(false)
504  , enum_value_(severity)
505  , record_(std::make_unique<boost::log::record>(
506  gSeverityLogger::get().open_record(keywords::severity = severity))) {
507  if (*record_) {
508  stream_ = std::make_unique<boost::log::record_ostream>(*record_);
509  }
510 }
int const enum_value_
Definition: Logger.h:250
std::unique_ptr< boost::log::record > record_
Definition: Logger.h:252
bool const is_channel_
Definition: Logger.h:249
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:253
logger::Logger::Logger ( Logger &&  )
default
logger::Logger::~Logger ( )

Definition at line 512 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_.

512  {
513  if (stream_) {
514  if (is_channel_) {
515  get_channel_logger(static_cast<Channel>(enum_value_))
516  .push_record(boost::move(stream_->get_record()));
517  } else {
518  gSeverityLogger::get().push_record(boost::move(stream_->get_record()));
519  }
520  }
521  if (!is_channel_ && static_cast<Severity>(enum_value_) == Severity::FATAL) {
522  if (FatalFunc fatal_func = g_fatal_func.load()) {
523  // set_once_fatal_func() prevents race condition.
524  // Exceptions thrown by (*fatal_func)() are propagated here.
525  std::call_once(g_fatal_func_flag, *fatal_func);
526  }
527 
528  abort();
529  }
530 }
int const enum_value_
Definition: Logger.h:250
std::once_flag g_fatal_func_flag
Definition: Logger.cpp:342
void(*)() noexcept FatalFunc
Definition: Logger.h:244
bool const is_channel_
Definition: Logger.h:249
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:341
ChannelLogger & get_channel_logger(Channel const channel)
Definition: Logger.cpp:477
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:253

+ Here is the call graph for this function:

Member Function Documentation

logger::Logger::operator bool ( ) const

Definition at line 532 of file Logger.cpp.

532  {
533  return static_cast<bool>(stream_);
534 }
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:253
boost::log::record_ostream & logger::Logger::stream ( char const *  file,
int  line 
)

Definition at line 554 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_.

554  {
555  return *stream_ << g_thread_local_ids.request_id_ << ' '
556  << g_thread_local_ids.thread_id_ << ' ' << filename(file) << ':' << line
557  << ' ';
558 }
RequestId request_id_
Definition: Logger.h:137
thread_local ThreadLocalIds g_thread_local_ids(0, 0)
std::unique_ptr< boost::log::record_ostream > stream_
Definition: Logger.h:253
tuple line
Definition: parse_ast.py:10
ThreadId thread_id_
Definition: Logger.h:138

+ Here is the call graph for this function:

Member Data Documentation

int const logger::Logger::enum_value_
private

Definition at line 250 of file Logger.h.

Referenced by ~Logger().

bool const logger::Logger::is_channel_
private

Definition at line 249 of file Logger.h.

Referenced by ~Logger().

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

Definition at line 252 of file Logger.h.

Referenced by Logger().

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

Definition at line 253 of file Logger.h.

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


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