OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logger Namespace Reference

Namespaces

 anonymous_namespace{Logger.cpp}
 

Classes

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

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

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

Definition at line 156 of file Logger.h.

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

Definition at line 109 of file Logger.h.

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

Definition at line 428 of file Logger.cpp.

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

Definition at line 262 of file Logger.cpp.

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

Definition at line 523 of file Logger.cpp.

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

Definition at line 466 of file Logger.cpp.

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

Definition at line 467 of file Logger.cpp.

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

Definition at line 153 of file Logger.h.

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

Definition at line 263 of file Logger.cpp.

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

Definition at line 159 of file Logger.h.

using logger::ThreadId = typedef uint64_t

Definition at line 312 of file Logger.h.

Enumeration Type Documentation

Enumerator
IR 
PTX 
ASM 
_NCHANNELS 

Definition at line 67 of file Logger.h.

Enumerator
DEBUG4 
DEBUG3 
DEBUG2 
DEBUG1 
INFO 
WARNING 
ERROR 
FATAL 
_NSEVERITIES 

Definition at line 79 of file Logger.h.

79  {
80  DEBUG4 = 0,
81  DEBUG3,
82  DEBUG2,
83  DEBUG1,
84  INFO,
85  WARNING,
86  ERROR,
87  FATAL,
88  _NSEVERITIES // number of severity levels
89 };

Function Documentation

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 219 of file Logger.h.

223  {
224  std::stringstream ss;
225  ss << "Check failed: " << xstr << op_str << ystr << " (" << x << op_str << y << ") ";
226  return new std::string(ss.str()); // Deleted by CHECK_OP macro.
227 }
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 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()) {
178  boost::system::error_code ec;
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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References CHECK, g_duration_tree_map, g_duration_tree_map_mutex, and g_thread_id.

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

Definition at line 180 of file Logger.h.

References g_any_active_channels.

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

180  {
181  extern bool g_any_active_channels;
182  return g_any_active_channels;
183 }
bool g_any_active_channels
Definition: Logger.cpp:277

+ Here is the caller graph for this function:

bool logger::fast_logging_check ( Severity  severity)
inline

Definition at line 185 of file Logger.h.

References g_min_active_severity.

185  {
187  return g_min_active_severity <= severity;
188 }
Severity g_min_active_severity
Definition: Logger.cpp:278
Severity
Definition: Logger.h:79
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(), and logger::Logger::stream().

62  {
63  return boost::filesystem::path(path).filename().string();
64 }

+ Here is the caller graph for this function:

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:

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, i, INFO, LOG, logger::LogOptions::max_files_, logger::LogOptions::severity_, and logger::LogOptions::severity_clog_.

Referenced by QueryRunner::QueryRunner::init(), CommandLineOptions::init_logging(), main(), ColumnarResults::mergeResults(), ResultSetManager::reduce(), Executor::reduceMultiDeviceResultSets(), FixedLengthEncoder< T, V >::updateStatsEncoded(), and NoneEncoder< T >::updateStatsEncoded().

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:194
Severity g_min_active_severity
Definition: Logger.cpp:278
Severity
Definition: Logger.h:79
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:

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

Definition at line 676 of file Logger.cpp.

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

+ Here is the call graph for this function:

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 }
template<typename... Ts>
Duration* logger::newDuration ( Severity  severity,
Ts &&...  args 
)

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

531  {
532  if (g_enable_debug_timer) {
533  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
534  auto& duration_tree_ptr = g_duration_tree_map[g_thread_id];
535  if (!duration_tree_ptr) {
536  duration_tree_ptr = std::make_unique<DurationTree>(g_thread_id, 0);
537  }
538  return duration_tree_ptr->newDuration(severity, std::forward<Ts>(args)...);
539  }
540  return nullptr; // Inactive - don't measure or report timing.
541 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:525
bool g_enable_debug_timer
Definition: Logger.cpp:17
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:528
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:526
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:71
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:100
std::ostream& logger::operator<< ( std::ostream &  out,
Channels const channels 
)

Definition at line 354 of file Logger.cpp.

References ChannelNames, and i.

354  {
355  int i = 0;
356  for (auto const channel : channels) {
357  out << (i++ ? " " : "") << ChannelNames.at(channel);
358  }
359  return out;
360 }
constexpr std::array< char const *, 3 > ChannelNames
Definition: Logger.h:69
std::ostream& logger::operator<< ( std::ostream &  out,
Severity const sev 
)

Definition at line 377 of file Logger.cpp.

References SeverityNames.

377  {
378  return out << SeverityNames.at(sev);
379 }
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:91
std::ostream& logger::operator<< ( std::ostream &  os,
Duration const duration 
)

Definition at line 543 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().

543  {
544  return os << std::setw(2 * duration.depth_) << ' ' << duration.value() << "ms start("
545  << duration.relative_start_time() << "ms) " << duration.name_ << ' '
546  << filename(duration.file_) << ':' << duration.line_;
547 }
std::string filename(char const *path)
Definition: Logger.cpp:62

+ Here is the call graph for this function:

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

Definition at line 549 of file Logger.cpp.

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

549  {
550  os << std::setw(2 * duration_tree.depth_) << ' ' << "New thread("
551  << duration_tree.thread_id_ << ')';
552  for (auto const& duration_tree_node : duration_tree.durations()) {
553  os << '\n' << duration_tree_node;
554  }
555  return os << '\n'
556  << std::setw(2 * duration_tree.depth_) << ' ' << "End thread("
557  << duration_tree.thread_id_ << ')';
558 }

+ Here is the call graph for this function:

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

Definition at line 561 of file Logger.cpp.

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

Definition at line 334 of file Logger.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 363 of file Logger.cpp.

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

363  {
364  std::string token;
365  in >> token;
366  unquote(token);
367  auto itr = std::find(SeverityNames.cbegin(), SeverityNames.cend(), token);
368  if (itr == SeverityNames.cend()) {
369  in.setstate(std::ios_base::failbit);
370  } else {
371  sev = static_cast<Severity>(itr - SeverityNames.cbegin());
372  }
373  return in;
374 }
Severity
Definition: Logger.h:79
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:91
void unquote(std::string &str)
Definition: Logger.cpp:323

+ Here is the call graph for this function:

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:69
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:91

+ Here is the caller graph for this function:

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:

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:

void logger::shutdown ( )

Definition at line 314 of file Logger.cpp.

Referenced by heartbeat(), EmbeddedDatabase::DBEngineImpl::reset(), TestProcessSignalHandler::shutdownSubsystemsAndExit(), startMapdServer(), and logger::LogShutdown::~LogShutdown().

314  {
315  static std::once_flag logger_flag;
316  std::call_once(logger_flag, []() { boost::log::core::get()->remove_all_sinks(); });
317 }

+ Here is the caller graph for this function:

Variable Documentation

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

Definition at line 69 of file Logger.h.

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

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

Definition at line 71 of file Logger.h.

Referenced by operator<<().

bool logger::g_any_active_channels {false}

Definition at line 277 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

std::mutex logger::g_duration_tree_map_mutex

Definition at line 525 of file Logger.cpp.

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

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

std::once_flag logger::g_fatal_func_flag

Definition at line 260 of file Logger.cpp.

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

Severity logger::g_min_active_severity {Severity::FATAL}

Definition at line 278 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

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

Definition at line 527 of file Logger.cpp.

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

Definition at line 91 of file Logger.h.

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

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

Definition at line 100 of file Logger.h.

Referenced by operator<<().