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

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, _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 *, 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

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

Definition at line 150 of file Logger.h.

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

Definition at line 103 of file Logger.h.

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

Definition at line 409 of file Logger.cpp.

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

Definition at line 258 of file Logger.cpp.

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

Definition at line 504 of file Logger.cpp.

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

Definition at line 447 of file Logger.cpp.

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

Definition at line 448 of file Logger.cpp.

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

Definition at line 147 of file Logger.h.

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

Definition at line 259 of file Logger.cpp.

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

Definition at line 153 of file Logger.h.

using logger::ThreadId = typedef uint64_t

Definition at line 306 of file Logger.h.

Enumeration Type Documentation

Enumerator
IR 
PTX 
_NCHANNELS 

Definition at line 61 of file Logger.h.

61 { IR = 0, PTX, _NCHANNELS };
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

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

References error_code, and filename().

Referenced by make_sink().

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

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

References CHECK(), g_duration_tree_map, g_duration_tree_map_mutex, g_enable_debug_timer, and g_thread_id.

702  {
703  if (g_enable_debug_timer) {
704  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
705  auto parent_itr = g_duration_tree_map.find(parent_thread_id);
706  CHECK(parent_itr != g_duration_tree_map.end());
707  auto const current_depth = parent_itr->second->currentDepth();
708  auto& duration_tree_ptr = g_duration_tree_map[g_thread_id];
709  CHECK(!duration_tree_ptr);
710  duration_tree_ptr = std::make_unique<DurationTree>(g_thread_id, current_depth + 1);
711  parent_itr->second->pushDurationTree(*duration_tree_ptr);
712  }
713 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:506
bool g_enable_debug_timer
Definition: Logger.cpp:17
CHECK(cgen_state)
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:509
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:507

+ Here is the call graph for this function:

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

+ Here is the caller graph for this function:

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:274
Severity
Definition: Logger.h:73
std::string logger::filename ( char const *  path)

Definition at line 62 of file Logger.cpp.

Referenced by create_or_replace_symlink(), com.omnisci.jdbc.KeyLoader::getDetails_pkcs12(), logger::LogOptions::LogOptions(), logger::JsonEncoder::operator()(), operator<<(), 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 160 of file Logger.cpp.

Referenced by set_formatter().

162  {
163  return pid ? pid->native_id() : 0;
164 }

+ Here is the caller graph for this function:

void logger::init ( LogOptions const &  log_opts)

Definition at line 276 of file Logger.cpp.

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

Referenced by QueryRunner::QueryRunner::init(), MapDProgramOptions::init_logging(), main(), ColumnarResults::mergeResults(), ResultSetManager::reduce(), and Executor::reduceMultiDeviceResultSets().

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

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

657  {
658  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
659  DurationTreeMap::const_iterator const itr = g_duration_tree_map.find(g_thread_id);
660  CHECK(itr != g_duration_tree_map.cend());
661  auto const& root_duration = itr->second->rootDuration();
662  if (auto log = Logger(root_duration.severity_)) {
663  log.stream(root_duration.file_, root_duration.line_) << *itr;
664  }
665  if (json_str) {
666  JsonEncoder json_encoder;
667  *json_str = json_encoder.str(*itr);
668  }
669  EraseDurationTrees erase_duration_trees;
670  erase_duration_trees(itr);
671 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:506
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
CHECK(cgen_state)
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:509
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:507

+ 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 221 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_.

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

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

References logger::LogOptions::severity_clog_.

262  {
263  auto sink = boost::make_shared<CONSOLE_SINK>();
264  boost::shared_ptr<std::ostream> clog(&std::clog, boost::null_deleter());
265  sink->locked_backend()->add_stream(clog);
266  sink->set_filter(log_opts.severity_clog_ <= severity);
267  set_formatter<Severity>(sink);
268  return sink;
269 }
template<typename... Ts>
Duration* logger::newDuration ( Severity  severity,
Ts &&...  args 
)

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

512  {
513  if (g_enable_debug_timer) {
514  std::lock_guard<std::mutex> lock_guard(g_duration_tree_map_mutex);
515  auto& duration_tree_ptr = g_duration_tree_map[g_thread_id];
516  if (!duration_tree_ptr) {
517  duration_tree_ptr = std::make_unique<DurationTree>(g_thread_id, 0);
518  }
519  return duration_tree_ptr->newDuration(severity, std::forward<Ts>(args)...);
520  }
521  return nullptr; // Inactive - don't measure or report timing.
522 }
std::mutex g_duration_tree_map_mutex
Definition: Logger.cpp:506
bool g_enable_debug_timer
Definition: Logger.cpp:17
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:509
DurationTreeMap g_duration_tree_map
Definition: Logger.cpp:507
boost::log::formatting_ostream& logger::operator<< ( boost::log::formatting_ostream &  strm,
boost::log::to_log_manip< Channel, tag::channel > const &  manip 
)

Definition at line 189 of file Logger.cpp.

References ChannelSymbols.

191  {
192  return strm << ChannelSymbols[manip.get()];
193 }
constexpr std::array< char, 2 > ChannelSymbols
Definition: Logger.h:65
boost::log::formatting_ostream& logger::operator<< ( boost::log::formatting_ostream &  strm,
boost::log::to_log_manip< Severity, tag::severity > const &  manip 
)

Definition at line 195 of file Logger.cpp.

References SeveritySymbols.

197  {
198  return strm << SeveritySymbols[manip.get()];
199 }
constexpr std::array< char, 8 > SeveritySymbols
Definition: Logger.h:94
std::ostream& logger::operator<< ( std::ostream &  out,
Channels const &  channels 
)

Definition at line 335 of file Logger.cpp.

References ChannelNames, and out.

335  {
336  int i = 0;
337  for (auto const channel : channels) {
338  out << (i++ ? " " : "") << ChannelNames.at(channel);
339  }
340  return out;
341 }
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
std::ostream& logger::operator<< ( std::ostream &  out,
Severity const &  sev 
)

Definition at line 358 of file Logger.cpp.

References SeverityNames.

358  {
359  return out << SeverityNames.at(sev);
360 }
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
std::ostream& logger::operator<< ( std::ostream &  os,
Duration const &  duration 
)

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

524  {
525  return os << std::setw(2 * duration.depth_) << ' ' << duration.value() << "ms start("
526  << duration.relative_start_time() << "ms) " << duration.name_ << ' '
527  << filename(duration.file_) << ':' << duration.line_;
528 }
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 530 of file Logger.cpp.

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

530  {
531  os << std::setw(2 * duration_tree.depth_) << ' ' << "New thread("
532  << duration_tree.thread_id_ << ')';
533  for (auto const& duration_tree_node : duration_tree.durations()) {
534  os << '\n' << duration_tree_node;
535  }
536  return os << '\n'
537  << std::setw(2 * duration_tree.depth_) << ' ' << "End thread("
538  << duration_tree.thread_id_ << ')';
539 }

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

543  {
544  auto itr = kv_pair.second->durations().cbegin();
545  auto const end = kv_pair.second->durations().cend();
546  auto const& root_duration = boost::get<Duration>(*itr);
547  os << "DEBUG_TIMER thread_id(" << kv_pair.first << ")\n"
548  << root_duration.value() << "ms total duration for " << root_duration.name_;
549  for (++itr; itr != end; ++itr) {
550  os << '\n' << *itr;
551  }
552  return os;
553 }
std::istream& logger::operator>> ( std::istream &  in,
Channels &  channels 
)

Definition at line 315 of file Logger.cpp.

References ChannelNames, and unquote().

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

+ Here is the call graph for this function:

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

Definition at line 344 of file Logger.cpp.

References SeverityNames, and unquote().

344  {
345  std::string token;
346  in >> token;
347  unquote(token);
348  auto itr = std::find(SeverityNames.cbegin(), SeverityNames.cend(), token);
349  if (itr == SeverityNames.cend()) {
350  in.setstate(std::ios_base::failbit);
351  } else {
352  sev = static_cast<Severity>(itr - SeverityNames.cbegin());
353  }
354  return in;
355 }
Severity
Definition: Logger.h:73
constexpr std::array< char const *, 8 > SeverityNames
Definition: Logger.h:85
bool unquote(std::string &str)

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

References ChannelNames, and SeverityNames.

Referenced by make_sink().

149  {
150  constexpr std::regex::flag_type flags = std::regex::ECMAScript | std::regex::optimize;
151  static std::regex const regex(R"(\{SEVERITY\})", flags);
152  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
153  return std::regex_replace(str, regex, ChannelNames[tag]);
154  } else {
155  return std::regex_replace(str, regex, SeverityNames[tag]);
156  }
157 }
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:

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

Definition at line 202 of file Logger.cpp.

References get_native_process_id().

202  {
203  if /*constexpr*/ (std::is_same<TAG, Channel>::value) {
204  sink->set_formatter(
205  expr::stream << expr::format_date_time<boost::posix_time::ptime>(
206  "TimeStamp", "%Y-%m-%dT%H:%M:%S.%f")
207  << ' ' << channel << ' '
208  << boost::phoenix::bind(&get_native_process_id, process_id.or_none())
209  << ' ' << expr::smessage);
210  } else {
211  sink->set_formatter(
212  expr::stream << expr::format_date_time<boost::posix_time::ptime>(
213  "TimeStamp", "%Y-%m-%dT%H:%M:%S.%f")
214  << ' ' << severity << ' '
215  << boost::phoenix::bind(&get_native_process_id, process_id.or_none())
216  << ' ' << expr::smessage);
217  }
218 }
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:160

+ Here is the call graph for this function:

void logger::set_once_fatal_func ( FatalFunc  fatal_func)

Definition at line 303 of file Logger.cpp.

References g_fatal_func.

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

303  {
304  if (g_fatal_func.exchange(fatal_func)) {
305  throw std::runtime_error(
306  "logger::set_once_fatal_func() should not be called more than once.");
307  }
308 }
std::atomic< FatalFunc > g_fatal_func
Definition: Logger.cpp:255

+ Here is the caller graph for this function:

void logger::shutdown ( )

Definition at line 310 of file Logger.cpp.

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

310  {
311  boost::log::core::get()->remove_all_sinks();
312 }

+ Here is the caller graph for this function:

ThreadId logger::thread_id ( )

Definition at line 715 of file Logger.cpp.

References g_thread_id.

Referenced by Executor::executeWorkUnitImpl(), Importer_NS::import_thread_delimited(), Importer_NS::import_thread_shapefile(), Importer_NS::Importer::importDelimited(), Importer_NS::Importer::importGDAL(), StringDictionary::populate_string_array_ids(), Parser::InsertIntoTableAsSelectStmt::populateData(), JoinHashTable::reify(), OverlapsJoinHashTable::reifyWithLayout(), and BaselineJoinHashTable::reifyWithLayout().

715  {
716  return g_thread_id;
717 }
ThreadId thread_local const g_thread_id
Definition: Logger.cpp:509

+ Here is the caller graph for this function:

Variable Documentation

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

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

Definition at line 65 of file Logger.h.

Referenced by operator<<().

bool logger::g_any_active_channels {false}

Definition at line 273 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

std::mutex logger::g_duration_tree_map_mutex

Definition at line 506 of file Logger.cpp.

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

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

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

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

Severity logger::g_min_active_severity {Severity::FATAL}

Definition at line 274 of file Logger.cpp.

Referenced by fast_logging_check(), and init().

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

Definition at line 508 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 85 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 94 of file Logger.h.

Referenced by operator<<().