OmniSciDB  29e35f4d58
logger Namespace Reference

Classes

class  DebugTimer
 
class  Duration
 
class  DurationTree
 
struct  EraseDurationTrees
 
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 DurationTreeMap = std::unordered_map< std::thread::id, std::unique_ptr< DurationTree > >
 
using Channels = std::set< Channel >
 
using FatalFunc = void(*)()
 
using ChannelLogger = boost::log::sources::channel_logger_mt< Channel >
 
using SeverityLogger = boost::log::sources::severity_logger_mt< Severity >
 

Enumerations

enum  Channel { IR = 0, PTX, _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::thread::id const thread_id)
 
void debugTimerNewThread (std::thread::id parent_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 gDurationTreeMapMutex
 
DurationTreeMap gDurationTreeMap
 
constexpr std::array< char const *, 2 > ChannelNames {"IR", "PTX"}
 
constexpr std::array< char, 2 > ChannelSymbols {'R', 'P'}
 
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 404 of file Logger.cpp.

◆ ClogSync

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

Definition at line 254 of file Logger.cpp.

◆ DurationTreeMap

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

Definition at line 480 of file Logger.cpp.

◆ DurationTreeNode

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

Definition at line 440 of file Logger.cpp.

◆ FatalFunc

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

Definition at line 147 of file Logger.h.

◆ FileSync

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

Definition at line 255 of file Logger.cpp.

◆ SeverityLogger

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

Definition at line 153 of file Logger.h.

Enumeration Type Documentation

◆ Channel

Enumerator
IR 
PTX 
_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 209 of file Logger.h.

213  {
214  std::stringstream ss;
215  ss << "Check failed: " << xstr << op_str << ystr << " (" << x << op_str << y << ") ";
216  return new std::string(ss.str()); // Deleted by CHECK_OP macro.
217 }

◆ 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 163 of file Logger.cpp.

References error_code, and filename().

Referenced by make_sink().

165  {
166  namespace fs = boost::filesystem;
167  return [weak_ptr,
168  symlink = std::move(symlink)](sinks::text_file_backend::stream_type& stream) {
169  if (boost::shared_ptr<SINK> sink = weak_ptr.lock()) {
171  fs::path const& file_name = sink->locked_backend()->get_current_file_name();
172  fs::path const symlink_path = file_name.parent_path() / symlink;
173  fs::remove(symlink_path, ec);
174  if (ec) {
175  stream << filename(__FILE__) << ':' << __LINE__ << ' ' << ec.message() << '\n';
176  }
177  fs::create_symlink(file_name.filename(), symlink_path, ec);
178  if (ec) {
179  stream << filename(__FILE__) << ':' << __LINE__ << ' ' << ec.message() << '\n';
180  }
181  }
182  };
183 }
std::string filename(char const *path)
Definition: Logger.cpp:58
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:

◆ debugTimerNewThread()

void logger::debugTimerNewThread ( std::thread::id  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 576 of file Logger.cpp.

References g_enable_debug_timer, gDurationTreeMap, and gDurationTreeMapMutex.

576  {
577  if (g_enable_debug_timer) {
578  auto const thread_id = std::this_thread::get_id();
579  if (thread_id != parent_thread_id) {
580  std::lock_guard<std::mutex> lock_guard(gDurationTreeMapMutex);
581  auto parent_itr = gDurationTreeMap.find(parent_thread_id);
582  if (parent_itr != gDurationTreeMap.end()) {
583  auto& duration_tree_ptr = gDurationTreeMap[thread_id];
584  if (!duration_tree_ptr) {
585  auto const current_depth = parent_itr->second->currentDepth();
586  duration_tree_ptr =
587  std::make_unique<DurationTree>(thread_id, current_depth + 1);
588  parent_itr->second->pushDurationTree(*duration_tree_ptr);
589  }
590  }
591  }
592  }
593 }
bool g_enable_debug_timer
Definition: Logger.cpp:17
std::mutex gDurationTreeMapMutex
Definition: Logger.cpp:482
DurationTreeMap gDurationTreeMap
Definition: Logger.cpp:483

◆ 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:269
+ 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:270
Severity
Definition: Logger.h:73

◆ filename()

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

Definition at line 58 of file Logger.cpp.

Referenced by create_or_replace_symlink(), com.omnisci.jdbc.KeyLoader::getDetails_pkcs12(), logger::LogOptions::LogOptions(), operator<<(), path_has_valid_filename(), File_Namespace::removeFile(), QueryRunner::QueryRunner::setIRFilename(), and logger::Logger::stream().

58  {
59  return boost::filesystem::path(path).filename().string();
60 }
+ 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 156 of file Logger.cpp.

Referenced by set_formatter().

158  {
159  return pid ? pid->native_id() : 0;
160 }
+ Here is the caller graph for this function:

◆ init()

void logger::init ( LogOptions const &  log_opts)

Definition at line 272 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 Importer_NS::Detector::Detector(), File_Namespace::FileMgr::getFileInfoForFileId(), Calcite::getInternalSessionProxyPassword(), Importer_NS::Loader::getReplicating(), QueryRunner::QueryRunner::init(), MapDProgramOptions::init_logging(), File_Namespace::GlobalFileMgr::isAllocationCapped(), Importer_NS::Loader::Loader(), main(), ColumnarResults::mergeResults(), ResultSetManager::reduce(), and Executor::reduceMultiDeviceResultSets().

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

◆ logAndEraseDurationTree()

void logger::logAndEraseDurationTree ( std::thread::id const  thread_id)

Definition at line 546 of file Logger.cpp.

References CHECK, gDurationTreeMap, gDurationTreeMapMutex, and logger::Logger::Logger().

Referenced by logger::DebugTimer::stop().

546  {
547  std::lock_guard<std::mutex> lock_guard(gDurationTreeMapMutex);
548  DurationTreeMap::const_iterator const itr = gDurationTreeMap.find(thread_id);
549  CHECK(itr != gDurationTreeMap.cend());
550  auto const& base_duration = itr->second->baseDuration();
551  if (auto log = Logger(base_duration.severity_)) {
552  log.stream(base_duration.file_, base_duration.line_) << *itr;
553  }
554  EraseDurationTrees const tree_trimmer;
555  tree_trimmer(itr);
556 }
std::mutex gDurationTreeMapMutex
Definition: Logger.cpp:482
DurationTreeMap gDurationTreeMap
Definition: Logger.cpp:483
#define CHECK(condition)
Definition: Logger.h:193
+ 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 217 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_.

219  {
220  auto sink = boost::make_shared<FILE_SINK>(
221  keywords::file_name =
222  full_log_dir / replace_braces(log_opts.file_name_pattern_, tag),
223  keywords::auto_flush = log_opts.auto_flush_,
224  keywords::rotation_size = log_opts.rotation_size_);
225  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
226  sink->set_filter(channel == static_cast<Channel>(tag));
227  set_formatter<Channel>(sink);
228  } else {
229  // INFO sink logs all other levels. Other sinks only log at their level or higher.
230  Severity const min_filter_level = static_cast<Severity>(tag) == Severity::INFO
231  ? log_opts.severity_
232  : static_cast<Severity>(tag);
233  sink->set_filter(min_filter_level <= severity);
234  set_formatter<Severity>(sink);
235  }
236  typename FILE_SINK::locked_backend_ptr backend = sink->locked_backend();
237  if (log_opts.rotate_daily_) {
238  backend->set_time_based_rotation(sinks::file::rotation_at_time_point(0, 0, 0));
239  }
240  backend->set_file_collector(
241  sinks::file::make_collector(keywords::target = full_log_dir,
242  keywords::max_files = log_opts.max_files_,
243  keywords::min_free_space = log_opts.min_free_space_));
244  backend->set_open_handler(create_or_replace_symlink(
245  boost::weak_ptr<FILE_SINK>(sink), replace_braces(log_opts.symlink_, tag)));
246  backend->scan_for_files();
247  return sink;
248 }
std::string replace_braces(std::string const &str, TAG const tag)
Definition: Logger.cpp:145
sinks::text_file_backend::open_handler_type create_or_replace_symlink(boost::weak_ptr< SINK > weak_ptr, std::string &&symlink)
Definition: Logger.cpp:163
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 258 of file Logger.cpp.

References logger::LogOptions::severity_clog_.

258  {
259  auto sink = boost::make_shared<CONSOLE_SINK>();
260  boost::shared_ptr<std::ostream> clog(&std::clog, boost::null_deleter());
261  sink->locked_backend()->add_stream(clog);
262  sink->set_filter(log_opts.severity_clog_ <= severity);
263  set_formatter<Severity>(sink);
264  return sink;
265 }

◆ newDuration()

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

Definition at line 486 of file Logger.cpp.

References run_benchmark_import::args, g_enable_debug_timer, gDurationTreeMap, and gDurationTreeMapMutex.

486  {
487  if (g_enable_debug_timer) {
488  auto const thread_id = std::this_thread::get_id();
489  std::lock_guard<std::mutex> lock_guard(gDurationTreeMapMutex);
490  auto& duration_tree_ptr = gDurationTreeMap[thread_id];
491  if (!duration_tree_ptr) {
492  duration_tree_ptr = std::make_unique<DurationTree>(thread_id, 0);
493  }
494  return duration_tree_ptr->newDuration(severity, std::forward<Ts>(args)...);
495  }
496  return nullptr; // Inactive - don't measure or report timing.
497 }
bool g_enable_debug_timer
Definition: Logger.cpp:17
std::mutex gDurationTreeMapMutex
Definition: Logger.cpp:482
DurationTreeMap gDurationTreeMap
Definition: Logger.cpp:483

◆ 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 185 of file Logger.cpp.

References ChannelSymbols.

187  {
188  return strm << ChannelSymbols[manip.get()];
189 }
constexpr std::array< char, 2 > 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 191 of file Logger.cpp.

References SeveritySymbols.

193  {
194  return strm << SeveritySymbols[manip.get()];
195 }
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 330 of file Logger.cpp.

References ChannelNames, and out.

330  {
331  int i = 0;
332  for (auto const channel : channels) {
333  out << (i++ ? " " : "") << ChannelNames.at(channel);
334  }
335  return out;
336 }
constexpr std::array< char const *, 2 > 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 352 of file Logger.cpp.

References SeverityNames.

352  {
353  return out << SeverityNames.at(sev);
354 }
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 499 of file Logger.cpp.

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

499  {
500  return os << std::setw(2 * duration.depth_) << ' ' << duration.value() << "ms "
501  << duration.name_ << ' ' << filename(duration.file_) << ':' << duration.line_;
502 }
std::string filename(char const *path)
Definition: Logger.cpp:58
+ 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 504 of file Logger.cpp.

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

504  {
505  os << std::setw(2 * duration_tree.depth_) << ' ' << "New thread("
506  << duration_tree.thread_id_ << ')';
507  for (auto const& duration_tree_node : duration_tree.durations()) {
508  os << '\n' << duration_tree_node;
509  }
510  return os << '\n'
511  << std::setw(2 * duration_tree.depth_) << ' ' << "End thread("
512  << duration_tree.thread_id_ << ')';
513 }
+ 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 516 of file Logger.cpp.

517  {
518  auto itr = kv_pair.second->durations().cbegin();
519  auto const end = kv_pair.second->durations().cend();
520  auto const& base_duration = boost::get<Duration>(*itr);
521  os << "DEBUG_TIMER thread_id(" << kv_pair.first << ")\n"
522  << base_duration.value() << "ms total duration for " << base_duration.name_;
523  for (++itr; itr != end; ++itr) {
524  os << '\n' << *itr;
525  }
526  return os;
527 }

◆ operator>>() [1/2]

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

Definition at line 311 of file Logger.cpp.

References ChannelNames.

311  {
312  std::string line;
313  std::getline(in, line);
314  std::regex const rex(R"(\w+)");
315  using TokenItr = std::regex_token_iterator<std::string::iterator>;
316  TokenItr const end;
317  for (TokenItr tok(line.begin(), line.end(), rex); tok != end; ++tok) {
318  auto itr = std::find(ChannelNames.cbegin(), ChannelNames.cend(), *tok);
319  if (itr == ChannelNames.cend()) {
320  in.setstate(std::ios_base::failbit);
321  break;
322  } else {
323  channels.emplace(static_cast<Channel>(itr - ChannelNames.cbegin()));
324  }
325  }
326  return in;
327 }
constexpr std::array< char const *, 2 > ChannelNames
Definition: Logger.h:63

◆ operator>>() [2/2]

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

Definition at line 339 of file Logger.cpp.

References SeverityNames.

339  {
340  std::string token;
341  in >> token;
342  auto itr = std::find(SeverityNames.cbegin(), SeverityNames.cend(), token);
343  if (itr == SeverityNames.cend()) {
344  in.setstate(std::ios_base::failbit);
345  } else {
346  sev = static_cast<Severity>(itr - SeverityNames.cbegin());
347  }
348  return in;
349 }
Severity
Definition: Logger.h:73
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:85

◆ replace_braces()

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

Definition at line 145 of file Logger.cpp.

References ChannelNames, and SeverityNames.

Referenced by make_sink().

145  {
146  constexpr std::regex::flag_type flags = std::regex::ECMAScript | std::regex::optimize;
147  static std::regex const regex(R"(\{SEVERITY\})", flags);
148  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
149  return std::regex_replace(str, regex, ChannelNames[tag]);
150  } else {
151  return std::regex_replace(str, regex, SeverityNames[tag]);
152  }
153 }
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:85
constexpr std::array< char const *, 2 > ChannelNames
Definition: Logger.h:63
+ Here is the caller graph for this function:

◆ set_formatter()

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

Definition at line 198 of file Logger.cpp.

References get_native_process_id().

198  {
199  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
200  sink->set_formatter(
201  expr::stream << expr::format_date_time<boost::posix_time::ptime>(
202  "TimeStamp", "%Y-%m-%dT%H:%M:%S.%f")
203  << ' ' << channel << ' '
204  << boost::phoenix::bind(&get_native_process_id, process_id.or_none())
205  << ' ' << expr::smessage);
206  } else {
207  sink->set_formatter(
208  expr::stream << expr::format_date_time<boost::posix_time::ptime>(
209  "TimeStamp", "%Y-%m-%dT%H:%M:%S.%f")
210  << ' ' << severity << ' '
211  << boost::phoenix::bind(&get_native_process_id, process_id.or_none())
212  << ' ' << expr::smessage);
213  }
214 }
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:156
+ Here is the call graph for this function:

◆ set_once_fatal_func()

void logger::set_once_fatal_func ( FatalFunc  fatal_func)

Definition at line 299 of file Logger.cpp.

References g_fatal_func.

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

299  {
300  if (g_fatal_func.exchange(fatal_func)) {
301  throw std::runtime_error(
302  "logger::set_once_fatal_func() should not be called more than once.");
303  }
304 }
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:251
+ Here is the caller graph for this function:

◆ shutdown()

void logger::shutdown ( )

Definition at line 306 of file Logger.cpp.

Referenced by heartbeat(), anonymous_namespace{QueryRunner.cpp}::mapd_signal_handler(), MapDHandler::max_bytes_for_thrift(), startMapdServer(), and logger::LogShutdown::~LogShutdown().

306  {
307  boost::log::core::get()->remove_all_sinks();
308 }
+ Here is the caller graph for this function:

Variable Documentation

◆ ChannelNames

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

Definition at line 63 of file Logger.h.

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

◆ ChannelSymbols

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

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 269 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

◆ g_fatal_func

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

Definition at line 251 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 252 of file Logger.cpp.

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

◆ g_min_active_severity

Severity logger::g_min_active_severity {Severity::FATAL}

Definition at line 270 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

◆ gDurationTreeMap

◆ gDurationTreeMapMutex

std::mutex logger::gDurationTreeMapMutex

Definition at line 482 of file Logger.cpp.

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

◆ 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<<().