| 77 | namespace logger { |
| 78 | |
| 79 | message::message(level_e _level) : std::ostream(&buffer_), level_{_level} { |
| 80 | const auto* its_logger = logger_impl::get(); |
| 81 | if (!its_logger) { |
| 82 | // May happen when trying to log during program termination |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | // Store logger config locally to avoid repeated access to atomics |
| 87 | // TODO: Simplify once access to logger config no longer needs to be threadsafe |
| 88 | auto its_cfg = its_logger->get_configuration(); |
| 89 | console_enabled_ = its_cfg.console_enabled; |
| 90 | dlt_enabled_ = its_cfg.dlt_enabled; |
| 91 | file_enabled_ = its_cfg.file_enabled; |
| 92 | |
| 93 | // Check whether this message should be logged at all |
| 94 | if ((console_enabled_ || dlt_enabled_ || file_enabled_) && level_ <= its_cfg.loglevel) { |
| 95 | buffer_.activate(); |
| 96 | when_ = std::chrono::system_clock::now(); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | message::~message() try { |
| 101 | if (!buffer_.is_active()) { |