OmniSciDB  2e3a973ef4
logger Namespace Reference

Namespaces

 anonymous_namespace{Logger.cpp}
 

Classes

class  DebugTimer
 
class  Duration
 
class  DurationTree
 
struct  EraseDurationTrees
 Depth-first search and erase all DurationTrees. Not thread-safe. More...
 
struct  GetDepth
 
class  JsonEncoder
 
class  Logger
 
class  LogOptions
 
struct  LogShutdown
 

Typedefs

using ClogSync = sinks::synchronous_sink< sinks::text_ostream_backend >
 
using FileSync = sinks::synchronous_sink< sinks::text_file_backend >
 
using Clock = std::chrono::steady_clock
 
using DurationTreeNode = boost::variant< Duration, DurationTree & >
 
using DurationTreeNodes = std::deque< DurationTreeNode >
 
using DurationTreeMap = std::unordered_map< ThreadId, std::unique_ptr< DurationTree > >
 
using Channels = std::set< Channel >
 
using FatalFunc = void(*)() noexcept
 
using ChannelLogger = boost::log::sources::channel_logger_mt< Channel >
 
using SeverityLogger = boost::log::sources::severity_logger_mt< Severity >
 
using ThreadId = uint64_t
 

Enumerations

enum  Channel { IR = 0, PTX, ASM, _NCHANNELS }
 
enum  Severity {
  DEBUG4 = 0, DEBUG3, DEBUG2, DEBUG1,
  INFO, WARNING, ERROR, FATAL,
  _NSEVERITIES
}
 

Functions

std::string filename (char const *path)
 
template<typename TAG >
std::string replace_braces (std::string const &str, TAG const tag)
 
boost::log::attributes::current_process_id::value_type::native_type get_native_process_id (boost::log::value_ref< boost::log::attributes::current_process_id::value_type, tag::process_id > const &pid)
 
template<typename SINK >
sinks::text_file_backend::open_handler_type create_or_replace_symlink (boost::weak_ptr< SINK > weak_ptr, std::string &&symlink)
 
boost::log::formatting_ostream & operator<< (boost::log::formatting_ostream &strm, boost::log::to_log_manip< Channel, tag::channel > const &manip)
 
boost::log::formatting_ostream & operator<< (boost::log::formatting_ostream &strm, boost::log::to_log_manip< Severity, tag::severity > const &manip)
 
template<typename TAG , typename SINK >
void set_formatter (SINK &sink)
 
template<typename FILE_SINK , typename TAG >
boost::shared_ptr< FILE_SINK > make_sink (LogOptions const &log_opts, boost::filesystem::path const &full_log_dir, TAG const tag)
 
template<typename CONSOLE_SINK >
boost::shared_ptr< CONSOLE_SINK > make_sink (LogOptions const &log_opts)
 
void init (LogOptions const &log_opts)
 
void set_once_fatal_func (FatalFunc fatal_func)
 
void shutdown ()
 
std::istream & operator>> (std::istream &in, Channels &channels)
 
std::ostream & operator<< (std::ostream &out, Channels const &channels)
 
std::istream & operator>> (std::istream &in, Severity &sev)
 
std::ostream & operator<< (std::ostream &out, Severity const &sev)
 
template<typename... Ts>
DurationnewDuration (Severity severity, Ts &&... args)
 
std::ostream & operator<< (std::ostream &os, Duration const &duration)
 
std::ostream & operator<< (std::ostream &os, DurationTree const &duration_tree)
 
boost::log::record_ostream & operator<< (boost::log::record_ostream &os, DurationTreeMap::const_reference kv_pair)
 
void logAndEraseDurationTree (std::string *json_str)
 
void debug_timer_new_thread (ThreadId parent_thread_id)
 
ThreadId thread_id ()
 
bool fast_logging_check (Channel)
 
bool fast_logging_check (Severity severity)
 
template<typename X , typename Y >
BOOST_NOINLINE std::string * check_failed (X const &x, Y const &y, char const *xstr, char const *ystr, char const *op_str)
 

Variables

std::atomic< FatalFuncg_fatal_func {nullptr}
 
std::once_flag g_fatal_func_flag
 
bool g_any_active_channels {false}
 
Severity g_min_active_severity {Severity::FATAL}
 
std::mutex g_duration_tree_map_mutex
 
DurationTreeMap g_duration_tree_map
 
std::atomic< ThreadIdg_next_thread_id {0}
 
ThreadId thread_local const g_thread_id = g_next_thread_id++
 
constexpr std::array< char const *, 3 > ChannelNames {"IR", "PTX", "ASM"}
 
constexpr std::array< char, 3 > ChannelSymbols {'R', 'P', 'A'}
 
constexpr std::array< char const *, 8 > SeverityNames
 
constexpr std::array< char, 8 > SeveritySymbols {'4', '3', '2', '1', 'I', 'W', 'E', 'F'}
 

Typedef Documentation

◆ ChannelLogger

using logger::ChannelLogger = typedef boost::log::sources::channel_logger_mt<Channel>

Definition at line 150 of file Logger.h.

◆ Channels

using logger::Channels = typedef std::set<Channel>

Definition at line 103 of file Logger.h.

◆ Clock

using logger::Clock = typedef std::chrono::steady_clock

Definition at line 427 of file Logger.cpp.

◆ ClogSync

using logger::ClogSync = typedef sinks::synchronous_sink<sinks::text_ostream_backend>

Definition at line 262 of file Logger.cpp.

◆ DurationTreeMap

using logger::DurationTreeMap = typedef std::unordered_map<ThreadId, std::unique_ptr<DurationTree> >

Definition at line 522 of file Logger.cpp.

◆ DurationTreeNode

using logger::DurationTreeNode = typedef boost::variant<Duration, DurationTree&>

Definition at line 465 of file Logger.cpp.

◆ DurationTreeNodes

using logger::DurationTreeNodes = typedef std::deque<DurationTreeNode>

Definition at line 466 of file Logger.cpp.

◆ FatalFunc

using logger::FatalFunc = typedef void (*)() noexcept

Definition at line 147 of file Logger.h.

◆ FileSync

using logger::FileSync = typedef sinks::synchronous_sink<sinks::text_file_backend>

Definition at line 263 of file Logger.cpp.

◆ SeverityLogger

using logger::SeverityLogger = typedef boost::log::sources::severity_logger_mt<Severity>

Definition at line 153 of file Logger.h.

◆ ThreadId

using logger::ThreadId = typedef uint64_t

Definition at line 306 of file Logger.h.

Enumeration Type Documentation

◆ Channel

Enumerator
IR 
PTX 
ASM 
_NCHANNELS 

Definition at line 61 of file Logger.h.

◆ Severity

Enumerator
DEBUG4 
DEBUG3 
DEBUG2 
DEBUG1 
INFO 
WARNING 
ERROR 
FATAL 
_NSEVERITIES 

Definition at line 73 of file Logger.h.

73  {
74  DEBUG4 = 0,
75  DEBUG3,
76  DEBUG2,
77  DEBUG1,
78  INFO,
79  WARNING,
80  ERROR,
81  FATAL,
82  _NSEVERITIES // number of severity levels
83 };

Function Documentation

◆ check_failed()

template<typename X , typename Y >
BOOST_NOINLINE std::string* logger::check_failed ( X const &  x,
Y const &  y,
char const *  xstr,
char const *  ystr,
char const *  op_str 
)

Definition at line 213 of file Logger.h.

217  {
218  std::stringstream ss;
219  ss << "Check failed: " << xstr << op_str << ystr << " (" << x << op_str << y << ") ";
220  return new std::string(ss.str()); // Deleted by CHECK_OP macro.
221 }

◆ create_or_replace_symlink()

template<typename SINK >
sinks::text_file_backend::open_handler_type logger::create_or_replace_symlink ( boost::weak_ptr< SINK >  weak_ptr,
std::string &&  symlink 
)

Definition at line 171 of file Logger.cpp.

References error_code, and filename().

Referenced by make_sink().

173  {
174  namespace fs = boost::filesystem;
175  return [weak_ptr,
176  symlink = std::move(symlink)](sinks::text_file_backend::stream_type& stream) {
177  if (boost::shared_ptr<SINK> sink = weak_ptr.lock()) {
179  fs::path const& file_name = sink->locked_backend()->get_current_file_name();
180  fs::path const symlink_path = file_name.parent_path() / symlink;
181  fs::remove(symlink_path, ec);
182  if (ec) {
183  stream << filename(__FILE__) << ':' << __LINE__ << ' ' << ec.message() << '\n';
184  }
185  fs::create_symlink(file_name.filename(), symlink_path, ec);
186  if (ec) {
187  stream << filename(__FILE__) << ':' << __LINE__ << ' ' << ec.message() << '\n';
188  }
189  }
190  };
191 }
std::string filename(char const *path)
Definition: Logger.cpp:62
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t const int64_t int32_t * error_code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debug_timer_new_thread()

void logger::debug_timer_new_thread ( ThreadId  parent_thread_id)

Call this when a new thread is spawned that will have timers that need to be associated with timers on the parent thread.

Definition at line 720 of file Logger.cpp.

References CHECK, g_duration_tree_map, g_duration_tree_map_mutex, and g_thread_id.

720  {
721  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
722  auto parent_itr = g_duration_tree_map.find(parent_thread_id);
723  CHECK(parent_itr != g_duration_tree_map.end());
724  auto const current_depth = parent_itr->second->currentDepth();
725  auto& duration_tree_ptr = g_duration_tree_map[g_thread_id];
726  CHECK(!duration_tree_ptr) << __func__ << " called twice on same thread.";
727  duration_tree_ptr = std::make_unique<DurationTree>(g_thread_id, current_depth + 1);
728  parent_itr->second->pushDurationTree(*duration_tree_ptr);
729 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:524
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:527
#define CHECK(condition)
Definition: Logger.h:197
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:525

◆ fast_logging_check() [1/2]

bool logger::fast_logging_check ( Channel  )
inline

Definition at line 174 of file Logger.h.

References g_any_active_channels.

Referenced by query_state::StdLog::log(), and query_state::StdLog::logCallStack().

174  {
175  extern bool g_any_active_channels;
176  return g_any_active_channels;
177 }
bool g_any_active_channels
Definition: Logger.cpp:277
+ Here is the caller graph for this function:

◆ fast_logging_check() [2/2]

bool logger::fast_logging_check ( Severity  severity)
inline

Definition at line 179 of file Logger.h.

References g_min_active_severity.

179  {
181  return g_min_active_severity <= severity;
182 }
Severity g_min_active_severity
Definition: Logger.cpp:278
Severity
Definition: Logger.h:73

◆ filename()

std::string logger::filename ( char const *  path)

Definition at line 62 of file Logger.cpp.

Referenced by import_export::QueryExporterGDAL::beginExport(), create_or_replace_symlink(), com.omnisci.jdbc.KeyLoader::getDetails_pkcs12(), logger::LogOptions::LogOptions(), logger::JsonEncoder::operator()(), operator<<(), anonymous_namespace{DBHandler.cpp}::path_has_valid_filename(), File_Namespace::removeFile(), logger::Logger::stream(), and to_lower().

62  {
63  return boost::filesystem::path(path).filename().string();
64 }
+ Here is the caller graph for this function:

◆ get_native_process_id()

boost::log::attributes::current_process_id::value_type::native_type logger::get_native_process_id ( boost::log::value_ref< boost::log::attributes::current_process_id::value_type, tag::process_id > const &  pid)

Definition at line 164 of file Logger.cpp.

Referenced by set_formatter().

166  {
167  return pid ? pid->native_id() : 0;
168 }
+ Here is the caller graph for this function:

◆ init()

void logger::init ( LogOptions const &  log_opts)

Definition at line 280 of file Logger.cpp.

References _NSEVERITIES, logger::LogOptions::channels_, logger::LogOptions::full_log_dir(), g_any_active_channels, g_min_active_severity, INFO, run_benchmark_import::level, LOG, logger::LogOptions::max_files_, logger::LogOptions::severity_, and logger::LogOptions::severity_clog_.

Referenced by import_export::Detector::Detector(), File_Namespace::FileMgr::getFileInfoForFileId(), Calcite::getInternalSessionProxyPassword(), import_export::Loader::getReplicating(), QueryRunner::QueryRunner::init(), CommandLineOptions::init_logging(), File_Namespace::GlobalFileMgr::isAllocationCapped(), import_export::Loader::Loader(), main(), ColumnarResults::mergeResults(), ResultSetManager::reduce(), and Executor::reduceMultiDeviceResultSets().

280  {
281  boost::shared_ptr<boost::log::core> core = boost::log::core::get();
282  // boost::log::add_common_attributes(); // LineID TimeStamp ProcessID ThreadID
283  core->add_global_attribute("TimeStamp", attr::local_clock());
284  core->add_global_attribute("ProcessID", attr::current_process_id());
285  if (0 < log_opts.max_files_) {
286  boost::filesystem::path const full_log_dir = log_opts.full_log_dir();
287  bool const log_dir_was_created = boost::filesystem::create_directory(full_log_dir);
288  // Don't create separate log sinks for anything less than Severity::INFO.
289  Severity const min_sink_level = std::max(Severity::INFO, log_opts.severity_);
290  for (int i = min_sink_level; i < Severity::_NSEVERITIES; ++i) {
291  Severity const level = static_cast<Severity>(i);
292  core->add_sink(make_sink<FileSync>(log_opts, full_log_dir, level));
293  }
294  g_min_active_severity = std::min(g_min_active_severity, log_opts.severity_);
295  if (log_dir_was_created) {
296  LOG(INFO) << "Log directory(" << full_log_dir.native() << ") created.";
297  }
298  for (auto const channel : log_opts.channels_) {
299  core->add_sink(make_sink<FileSync>(log_opts, full_log_dir, channel));
300  }
301  g_any_active_channels = !log_opts.channels_.empty();
302  }
303  core->add_sink(make_sink<ClogSync>(log_opts));
304  g_min_active_severity = std::min(g_min_active_severity, log_opts.severity_clog_);
305 }
#define LOG(tag)
Definition: Logger.h:188
Severity g_min_active_severity
Definition: Logger.cpp:278
Severity
Definition: Logger.h:73
bool g_any_active_channels
Definition: Logger.cpp:277
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logAndEraseDurationTree()

void logger::logAndEraseDurationTree ( std::string *  json_str)

Definition at line 675 of file Logger.cpp.

References CHECK, g_duration_tree_map, g_duration_tree_map_mutex, g_thread_id, logger::Logger::Logger(), and logger::JsonEncoder::str().

Referenced by logger::DebugTimer::stop(), and logger::DebugTimer::stopAndGetJson().

675  {
676  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
677  DurationTreeMap::const_iterator const itr = g_duration_tree_map.find(g_thread_id);
678  CHECK(itr != g_duration_tree_map.cend());
679  auto const& root_duration = itr->second->rootDuration();
680  if (auto log = Logger(root_duration.severity_)) {
681  log.stream(root_duration.file_, root_duration.line_) << *itr;
682  }
683  if (json_str) {
684  JsonEncoder json_encoder;
685  *json_str = json_encoder.str(*itr);
686  }
687  EraseDurationTrees erase_duration_trees;
688  erase_duration_trees(itr);
689 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:524
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:527
#define CHECK(condition)
Definition: Logger.h:197
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:525
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_sink() [1/2]

template<typename FILE_SINK , typename TAG >
boost::shared_ptr<FILE_SINK> logger::make_sink ( LogOptions const &  log_opts,
boost::filesystem::path const &  full_log_dir,
TAG const  tag 
)

Definition at line 225 of file Logger.cpp.

References logger::LogOptions::auto_flush_, create_or_replace_symlink(), logger::LogOptions::file_name_pattern_, INFO, logger::LogOptions::max_files_, logger::LogOptions::min_free_space_, replace_braces(), logger::LogOptions::rotate_daily_, logger::LogOptions::rotation_size_, logger::LogOptions::severity_, and logger::LogOptions::symlink_.

227  {
228  auto sink = boost::make_shared<FILE_SINK>(
229  keywords::file_name =
230  full_log_dir / replace_braces(log_opts.file_name_pattern_, tag),
231  keywords::auto_flush = log_opts.auto_flush_,
232  keywords::rotation_size = log_opts.rotation_size_);
233  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
234  sink->set_filter(channel == static_cast<Channel>(tag));
235  set_formatter<Channel>(sink);
236  } else {
237  // INFO sink logs all other levels. Other sinks only log at their level or higher.
238  Severity const min_filter_level = static_cast<Severity>(tag) == Severity::INFO
239  ? log_opts.severity_
240  : static_cast<Severity>(tag);
241  sink->set_filter(min_filter_level <= severity);
242  set_formatter<Severity>(sink);
243  }
244  typename FILE_SINK::locked_backend_ptr backend = sink->locked_backend();
245  if (log_opts.rotate_daily_) {
246  backend->set_time_based_rotation(sinks::file::rotation_at_time_point(0, 0, 0));
247  }
248  backend->set_file_collector(
249  sinks::file::make_collector(keywords::target = full_log_dir,
250  keywords::max_files = log_opts.max_files_,
251  keywords::min_free_space = log_opts.min_free_space_));
252  backend->set_open_handler(create_or_replace_symlink(
253  boost::weak_ptr<FILE_SINK>(sink), replace_braces(log_opts.symlink_, tag)));
254  backend->scan_for_files();
255  return sink;
256 }
std::string replace_braces(std::string const &str, TAG const tag)
Definition: Logger.cpp:153
sinks::text_file_backend::open_handler_type create_or_replace_symlink(boost::weak_ptr< SINK > weak_ptr, std::string &&symlink)
Definition: Logger.cpp:171
Severity
Definition: Logger.h:73
+ Here is the call graph for this function:

◆ make_sink() [2/2]

template<typename CONSOLE_SINK >
boost::shared_ptr<CONSOLE_SINK> logger::make_sink ( LogOptions const &  log_opts)

Definition at line 266 of file Logger.cpp.

References logger::LogOptions::severity_clog_.

266  {
267  auto sink = boost::make_shared<CONSOLE_SINK>();
268  boost::shared_ptr<std::ostream> clog(&std::clog, boost::null_deleter());
269  sink->locked_backend()->add_stream(clog);
270  sink->set_filter(log_opts.severity_clog_ <= severity);
271  set_formatter<Severity>(sink);
272  return sink;
273 }

◆ newDuration()

template<typename... Ts>
Duration* logger::newDuration ( Severity  severity,
Ts &&...  args 
)

Definition at line 530 of file Logger.cpp.

References run_benchmark_import::args, g_duration_tree_map, g_duration_tree_map_mutex, g_enable_debug_timer, and g_thread_id.

530  {
531  if (g_enable_debug_timer) {
532  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
533  auto& duration_tree_ptr = g_duration_tree_map[g_thread_id];
534  if (!duration_tree_ptr) {
535  duration_tree_ptr = std::make_unique<DurationTree>(g_thread_id, 0);
536  }
537  return duration_tree_ptr->newDuration(severity, std::forward<Ts>(args)...);
538  }
539  return nullptr; // Inactive - don't measure or report timing.
540 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:524
bool g_enable_debug_timer
Definition: Logger.cpp:17
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:527
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:525

◆ operator<<() [1/7]

boost::log::formatting_ostream& logger::operator<< ( boost::log::formatting_ostream &  strm,
boost::log::to_log_manip< Channel, tag::channel > const &  manip 
)

Definition at line 193 of file Logger.cpp.

References ChannelSymbols.

195  {
196  return strm << ChannelSymbols[manip.get()];
197 }
constexpr std::array< char, 3 > ChannelSymbols
Definition: Logger.h:65

◆ operator<<() [2/7]

boost::log::formatting_ostream& logger::operator<< ( boost::log::formatting_ostream &  strm,
boost::log::to_log_manip< Severity, tag::severity > const &  manip 
)

Definition at line 199 of file Logger.cpp.

References SeveritySymbols.

201  {
202  return strm << SeveritySymbols[manip.get()];
203 }
constexpr std::array< char, 8 > SeveritySymbols
Definition: Logger.h:94

◆ operator<<() [3/7]

std::ostream& logger::operator<< ( std::ostream &  out,
Channels const &  channels 
)

Definition at line 353 of file Logger.cpp.

References ChannelNames, and out.

353  {
354  int i = 0;
355  for (auto const channel : channels) {
356  out << (i++ ? " " : "") << ChannelNames.at(channel);
357  }
358  return out;
359 }
constexpr std::array< char const *, 3 > ChannelNames
Definition: Logger.h:63
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t ** out

◆ operator<<() [4/7]

std::ostream& logger::operator<< ( std::ostream &  out,
Severity const &  sev 
)

Definition at line 376 of file Logger.cpp.

References SeverityNames.

376  {
377  return out << SeverityNames.at(sev);
378 }
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:85
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t ** out

◆ operator<<() [5/7]

std::ostream& logger::operator<< ( std::ostream &  os,
Duration const &  duration 
)

Definition at line 542 of file Logger.cpp.

References logger::Duration::depth_, logger::Duration::file_, filename(), logger::Duration::line_, logger::Duration::name_, logger::Duration::relative_start_time(), and logger::Duration::value().

542  {
543  return os << std::setw(2 * duration.depth_) << ' ' << duration.value() << "ms start("
544  << duration.relative_start_time() << "ms) " << duration.name_ << ' '
545  << filename(duration.file_) << ':' << duration.line_;
546 }
std::string filename(char const *path)
Definition: Logger.cpp:62
+ Here is the call graph for this function:

◆ operator<<() [6/7]

std::ostream& logger::operator<< ( std::ostream &  os,
DurationTree const &  duration_tree 
)

Definition at line 548 of file Logger.cpp.

References logger::DurationTree::depth_, logger::DurationTree::durations(), and logger::DurationTree::thread_id_.

548  {
549  os << std::setw(2 * duration_tree.depth_) << ' ' << "New thread("
550  << duration_tree.thread_id_ << ')';
551  for (auto const& duration_tree_node : duration_tree.durations()) {
552  os << '\n' << duration_tree_node;
553  }
554  return os << '\n'
555  << std::setw(2 * duration_tree.depth_) << ' ' << "End thread("
556  << duration_tree.thread_id_ << ')';
557 }
+ Here is the call graph for this function:

◆ operator<<() [7/7]

boost::log::record_ostream& logger::operator<< ( boost::log::record_ostream &  os,
DurationTreeMap::const_reference  kv_pair 
)

Definition at line 560 of file Logger.cpp.

References parse_ast::end.

561  {
562  auto itr = kv_pair.second->durations().cbegin();
563  auto const end = kv_pair.second->durations().cend();
564  auto const& root_duration = boost::get<Duration>(*itr);
565  os << "DEBUG_TIMER thread_id(" << kv_pair.first << ")\n"
566  << root_duration.value() << "ms total duration for " << root_duration.name_;
567  for (++itr; itr != end; ++itr) {
568  os << '\n' << *itr;
569  }
570  return os;
571 }

◆ operator>>() [1/2]

std::istream& logger::operator>> ( std::istream &  in,
Channels channels 
)

Definition at line 333 of file Logger.cpp.

References ChannelNames, parse_ast::end, parse_ast::line, and logger::anonymous_namespace{Logger.cpp}::unquote().

333  {
334  std::string line;
335  std::getline(in, line);
336  unquote(line);
337  std::regex const rex(R"(\w+)");
338  using TokenItr = std::regex_token_iterator<std::string::iterator>;
339  TokenItr const end;
340  for (TokenItr tok(line.begin(), line.end(), rex); tok != end; ++tok) {
341  auto itr = std::find(ChannelNames.cbegin(), ChannelNames.cend(), *tok);
342  if (itr == ChannelNames.cend()) {
343  in.setstate(std::ios_base::failbit);
344  break;
345  } else {
346  channels.emplace(static_cast<Channel>(itr - ChannelNames.cbegin()));
347  }
348  }
349  return in;
350 }
constexpr std::array< char const *, 3 > ChannelNames
Definition: Logger.h:63
void unquote(std::string &str)
Definition: Logger.cpp:322
+ Here is the call graph for this function:

◆ operator>>() [2/2]

std::istream& logger::operator>> ( std::istream &  in,
Severity sev 
)

Definition at line 362 of file Logger.cpp.

References SeverityNames, and logger::anonymous_namespace{Logger.cpp}::unquote().

362  {
363  std::string token;
364  in >> token;
365  unquote(token);
366  auto itr = std::find(SeverityNames.cbegin(), SeverityNames.cend(), token);
367  if (itr == SeverityNames.cend()) {
368  in.setstate(std::ios_base::failbit);
369  } else {
370  sev = static_cast<Severity>(itr - SeverityNames.cbegin());
371  }
372  return in;
373 }
Severity
Definition: Logger.h:73
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:85
void unquote(std::string &str)
Definition: Logger.cpp:322
+ Here is the call graph for this function:

◆ replace_braces()

template<typename TAG >
std::string logger::replace_braces ( std::string const &  str,
TAG const  tag 
)

Definition at line 153 of file Logger.cpp.

References ChannelNames, and SeverityNames.

Referenced by make_sink().

153  {
154  constexpr std::regex::flag_type flags = std::regex::ECMAScript | std::regex::optimize;
155  static std::regex const regex(R"(\{SEVERITY\})", flags);
156  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
157  return std::regex_replace(str, regex, ChannelNames[tag]);
158  } else {
159  return std::regex_replace(str, regex, SeverityNames[tag]);
160  }
161 }
constexpr std::array< char const *, 3 > ChannelNames
Definition: Logger.h:63
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:85
+ Here is the caller graph for this function:

◆ set_formatter()

template<typename TAG , typename SINK >
void logger::set_formatter ( SINK &  sink)

Definition at line 206 of file Logger.cpp.

References get_native_process_id().

206  {
207  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
208  sink->set_formatter(
209  expr::stream << expr::format_date_time<boost::posix_time::ptime>(
210  "TimeStamp", "%Y-%m-%dT%H:%M:%S.%f")
211  << ' ' << channel << ' '
212  << boost::phoenix::bind(&get_native_process_id, process_id.or_none())
213  << ' ' << expr::smessage);
214  } else {
215  sink->set_formatter(
216  expr::stream << expr::format_date_time<boost::posix_time::ptime>(
217  "TimeStamp", "%Y-%m-%dT%H:%M:%S.%f")
218  << ' ' << severity << ' '
219  << boost::phoenix::bind(&get_native_process_id, process_id.or_none())
220  << ' ' << expr::smessage);
221  }
222 }
boost::log::attributes::current_process_id::value_type::native_type get_native_process_id(boost::log::value_ref< boost::log::attributes::current_process_id::value_type, tag::process_id > const &pid)
Definition: Logger.cpp:164
+ Here is the call graph for this function:

◆ set_once_fatal_func()

void logger::set_once_fatal_func ( FatalFunc  fatal_func)

Definition at line 307 of file Logger.cpp.

References g_fatal_func.

Referenced by QueryRunner::QueryRunner::QueryRunner().

307  {
308  if (g_fatal_func.exchange(fatal_func)) {
309  throw std::runtime_error(
310  "logger::set_once_fatal_func() should not be called more than once.");
311  }
312 }
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:259
+ Here is the caller graph for this function:

◆ shutdown()

void logger::shutdown ( )

Definition at line 314 of file Logger.cpp.

Referenced by heartbeat(), DBHandler::max_bytes_for_thrift(), TestProcessSignalHandler::shutdownSubsystemsAndExit(), startMapdServer(), and logger::LogShutdown::~LogShutdown().

314  {
315  boost::log::core::get()->remove_all_sinks();
316 }
+ Here is the caller graph for this function:

◆ thread_id()

Variable Documentation

◆ ChannelNames

constexpr std::array<char const*, 3> logger::ChannelNames {"IR", "PTX", "ASM"}

Definition at line 63 of file Logger.h.

Referenced by operator<<(), operator>>(), replace_braces(), and logger::LogOptions::set_options().

◆ ChannelSymbols

constexpr std::array<char, 3> logger::ChannelSymbols {'R', 'P', 'A'}

Definition at line 65 of file Logger.h.

Referenced by operator<<().

◆ g_any_active_channels

bool logger::g_any_active_channels {false}

Definition at line 277 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

◆ g_duration_tree_map

◆ g_duration_tree_map_mutex

std::mutex logger::g_duration_tree_map_mutex

Definition at line 524 of file Logger.cpp.

Referenced by debug_timer_new_thread(), logAndEraseDurationTree(), and newDuration().

◆ g_fatal_func

std::atomic<FatalFunc> logger::g_fatal_func {nullptr}

Definition at line 259 of file Logger.cpp.

Referenced by set_once_fatal_func(), and logger::Logger::~Logger().

◆ g_fatal_func_flag

std::once_flag logger::g_fatal_func_flag

Definition at line 260 of file Logger.cpp.

Referenced by logger::Logger::~Logger().

◆ g_min_active_severity

Severity logger::g_min_active_severity {Severity::FATAL}

Definition at line 278 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

◆ g_next_thread_id

std::atomic<ThreadId> logger::g_next_thread_id {0}

Definition at line 526 of file Logger.cpp.

◆ g_thread_id

ThreadId thread_local const logger::g_thread_id = g_next_thread_id++

◆ SeverityNames

constexpr std::array<char const*, 8> logger::SeverityNames
Initial value:
{"DEBUG4",
"DEBUG3",
"DEBUG2",
"DEBUG1",
"INFO",
"WARNING",
"ERROR",
"FATAL"}

Definition at line 85 of file Logger.h.

Referenced by operator<<(), operator>>(), replace_braces(), and logger::LogOptions::set_options().

◆ SeveritySymbols

constexpr std::array<char, 8> logger::SeveritySymbols {'4', '3', '2', '1', 'I', 'W', 'E', 'F'}

Definition at line 94 of file Logger.h.

Referenced by operator<<().