59 else if (s ==
"ERROR")
65 else if (s ==
"DEBUG")
67 else if (s ==
"TRACE")
72 NDN_THROW(std::invalid_argument(
"unrecognized log level '" + std::string(s) +
"'"));
76 isValidLoggerName(std::string_view name)
78 if (name.empty() || name.front() ==
'.' || name.back() ==
'.' ||
79 name.find(
"..") != std::string_view::npos) {
83 constexpr std::string_view okChars{
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~#%_<>.-"sv};
84 return name.find_first_not_of(okChars) == std::string_view::npos;
90 if (!isValidLoggerName(m_moduleName)) {
91 NDN_THROW(std::invalid_argument(
"Logger name '" + m_moduleName +
"' is invalid"));
94 this->add_attribute(log::module.get_name(), boost::log::attributes::constant(m_moduleName));
95 Logging::get().addLoggerImpl(*
this);
101 if (!isValidLoggerName(name)) {
102 NDN_THROW(std::invalid_argument(
"Logger name '"s + name +
"' is invalid"));
104 Logging::get().registerLoggerNameImpl(name);
static void registerModuleName(const char *name)
void setLevel(LogLevel level)
std::string to_string(const errinfo_stacktrace &x)
LogLevel parseLogLevel(std::string_view s)
Parse LogLevel from a string.
std::ostream & operator<<(std::ostream &os, LogLevel level)
Output LogLevel as 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