62 else if (s ==
"ERROR")
68 else if (s ==
"DEBUG")
70 else if (s ==
"TRACE")
75 NDN_THROW(std::invalid_argument(
"unrecognized log level '" + s +
"'"));
83 isValidLoggerName(
const std::string& name)
86 const char* okChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~#%_<>.-";
87 if (std::strspn(name.c_str(), okChars) != name.size()) {
90 if (name.empty() || name.front() ==
'.' || name.back() ==
'.') {
93 if (name.find(
"..") != std::string::npos) {
102 if (!isValidLoggerName(m_moduleName)) {
103 NDN_THROW(std::invalid_argument(
"Logger name '" + m_moduleName +
"' is invalid"));
106 this->add_attribute(log::module.get_name(), boost::log::attributes::constant<std::string>(m_moduleName));
107 Logging::get().addLoggerImpl(*
this);
113 std::string moduleName(name);
114 if (!isValidLoggerName(moduleName)) {
115 NDN_THROW(std::invalid_argument(
"Logger name '" + moduleName +
"' is invalid"));
117 Logging::get().registerLoggerNameImpl(std::move(moduleName));
static void registerModuleName(const char *name)
void setLevel(LogLevel level)
std::string to_string(const errinfo_stacktrace &x)
std::ostream & operator<<(std::ostream &os, LogLevel level)
Output LogLevel as a string.
LogLevel parseLogLevel(const std::string &s)
Parse LogLevel from a string.
LogLevel
Indicates the severity level of a log message.
@ FATAL
fatal (will be logged unconditionally)
@ TRACE
trace messages (most verbose)
@ INFO
informational messages
@ ERROR
serious error messages
constexpr std::underlying_type_t< T > to_underlying(T val) noexcept