diff --git a/include/ircd/logger.h b/include/ircd/logger.h index 51f03a3d9..555a2897e 100644 --- a/include/ircd/logger.h +++ b/include/ircd/logger.h @@ -94,8 +94,8 @@ struct ircd::log::log { string_view name; // name of this logger char snote; // snomask character - bool cmasked {true}; // currently in the console mask (enabled) - bool fmasked {true}; // currently in the file mask (enabled) + bool cmasked; // currently in the console mask (enabled) + bool fmasked; // currently in the file mask (enabled) public: template void operator()(const level &, const string_view &fmt, args&&...); @@ -151,6 +151,8 @@ struct ircd::log::log #endif log(const string_view &name, const char &snote = '\0'); + log(log &&) = delete; + log(const log &) = delete; static bool exists(const log *const &ptr); static log *find(const string_view &name); diff --git a/ircd/logger.cc b/ircd/logger.cc index 56a7480fa..6d9dacd7b 100644 --- a/ircd/logger.cc +++ b/ircd/logger.cc @@ -19,6 +19,13 @@ namespace ircd::log extern const std::array()> default_ansi; extern std::array()> confs; + extern conf::item unmask_file; + extern conf::item unmask_console; + extern conf::item mask_file; + extern conf::item mask_console; + static bool is_conf_mask_file(const string_view &name); + static bool is_conf_mask_console(const string_view &name); + std::array()> file; std::array()> console_quiet_stdout; std::array()> console_quiet_stderr; @@ -318,6 +325,14 @@ ircd::log::log::log(const string_view &name, const char &snote) :name{name} ,snote{snote} +,cmasked +{ + is_conf_mask_console(name) +} +,fmasked +{ + is_conf_mask_file(name) +} { for(const auto *const &other : list) { @@ -661,6 +676,84 @@ ircd::smalldate(const time_t <ime) return buf; } +bool +ircd::log::is_conf_mask_console(const string_view &name) +{ + if(token_exists(string_view(mask_console), ' ', name)) + return true; + + if(token_exists(string_view(unmask_console), ' ', name)) + return false; + + // When nothing is in the list then we consider this item masked. + return empty(string_view(mask_console)); +} + +bool +ircd::log::is_conf_mask_file(const string_view &name) +{ + if(token_exists(string_view(mask_file), ' ', name)) + return true; + + if(token_exists(string_view(unmask_file), ' ', name)) + return false; + + // When nothing is in the list then we consider this item masked. + return empty(string_view(mask_file)); +} + +decltype(ircd::log::unmask_file) +ircd::log::unmask_file +{ + { + { "name", "ircd.log.unmask.file" }, + { "default", string_view{} }, + }, [] + { + if(!empty(string_view(unmask_file))) + file_unmask(tokens(unmask_file, ' ')); + } +}; + +decltype(ircd::log::unmask_console) +ircd::log::unmask_console +{ + { + { "name", "ircd.log.unmask.console" }, + { "default", string_view{} }, + }, [] + { + if(!empty(string_view(unmask_console))) + console_unmask(tokens(unmask_console, ' ')); + } +}; + +decltype(ircd::log::mask_file) +ircd::log::mask_file +{ + { + { "name", "ircd.log.mask.file" }, + { "default", string_view{} }, + }, [] + { + if(!empty(string_view(mask_file))) + file_mask(tokens(mask_file, ' ')); + } +}; + +decltype(ircd::log::mask_console) +ircd::log::mask_console +{ + { + { "name", "ircd.log.mask.console" }, + { "default", string_view{} }, + }, [] + { + if(!empty(string_view(mask_console))) + console_mask(tokens(mask_console, ' ')); + } +}; + decltype(ircd::log::confs) ircd::log::confs {{