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 +
"'"));
79 isValidLoggerName(
const std::string& name)
82 const char* okChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~#%_<>.-";
83 if (std::strspn(name.c_str(), okChars) != name.size()) {
86 if (name.empty() || name.front() ==
'.' || name.back() ==
'.') {
89 if (name.find(
"..") != std::string::npos) {
98 if (!isValidLoggerName(m_moduleName)) {
99 NDN_THROW(std::invalid_argument(
"Logger name '" + m_moduleName +
"' is invalid"));
102 this->add_attribute(log::module.get_name(), boost::log::attributes::constant<std::string>(m_moduleName));
103 Logging::get().addLoggerImpl(*
this);
109 std::string moduleName(name);
110 if (!isValidLoggerName(moduleName)) {
111 NDN_THROW(std::invalid_argument(
"Logger name '" + moduleName +
"' is invalid"));
113 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