| Coverage Report |
 |
|
|
 |
: /*
: Copyright (c) 2025 Giuseppe Roberti.
: All rights reserved.
:
: Redistribution and use in source and binary forms, with or without modification,
: are permitted provided that the following conditions are met:
:
: 1. Redistributions of source code must retain the above copyright notice, this
: list of conditions and the following disclaimer.
:
: 2. Redistributions in binary form must reproduce the above copyright notice,
: this list of conditions and the following disclaimer in the documentation and/or
: other materials provided with the distribution.
:
: 3. Neither the name of the copyright holder nor the names of its contributors
: may be used to endorse or promote products derived from this software without
: specific prior written permission.
:
: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
: ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
: */
: #pragma once
:
: #include "pars/log.h"
:
: namespace pars::app
: {
:
: struct with_default_setup
: {
: private:
: const char* default_pattern()
: {
0 / 1 : return "%^[%H:%M:%S.%f %z] [%6P %6t] [%L]: %$%v";
: }
:
: const char* default_pattern_with_source_loc()
: {
0 / 1 : return "%^[%H:%M:%S.%f %z] [%6P %6t] [%L]: %$%v \x1b[90m(%s:%#)\x1b[0m";
: }
:
: public:
: void enable_source_loc_logging()
: {
0 / 1 : spdlog::set_pattern(default_pattern_with_source_loc());
: }
:
: void setup()
: {
0 / 1 : if constexpr (pars_log_enabled)
: {
0 / 1 : using namespace spdlog;
:
0 / 1 : /// sinks
:
0 / 1 : std::vector<sink_ptr> sinks;
:
0 / 1 : auto stderr_s = std::make_shared<sinks::stderr_color_sink_mt>();
:
0 / 1 : if constexpr (pars_log_enable_stderr)
: {
0 / 1 : auto stderr_sink = std::make_shared<sinks::stderr_color_sink_mt>();
:
0 / 1 : sinks.push_back(stderr_s);
: }
:
0 / 1 : if constexpr (pars_log_enable_file)
: {
0 / 1 : auto file_s = std::make_shared<sinks::basic_file_sink_mt>("pars.log");
:
0 / 1 : sinks.push_back(file_s);
: }
:
0 / 1 : #if defined(PARS_LOG_ENABLE_MSVC)
0 / 1 : auto msvc_s = std::make_shared<sinks::msvc_sink_mt>();
:
0 / 1 : sinks.push_back(msvc_s);
0 / 1 : #endif
:
0 / 1 : #if defined(PARS_LOG_ENABLE_SYSLOG)
0 / 1 : auto syslog_s = std::make_shared<sinks::syslog_sink_mt>(
0 / 1 : "pars", LOG_CONS | LOG_NDELAY, LOG_LOCAL2, true);
:
0 / 1 : sinks.push_back(syslog_s);
0 / 1 : #endif
:
0 / 1 : /// register pars logger and set as default
:
: {
0 / 1 : auto default_l = std::make_shared<logger>("pars");
:
0 / 1 : // default_l->set_pattern(default_pattern);
:
0 / 1 : default_l->sinks() = sinks;
:
0 / 1 : register_logger(default_l);
:
0 / 1 : set_pattern(default_pattern());
:
0 / 1 : set_default_logger(default_l);
:
0 / 1 : set_level(static_cast<level::level_enum>(SPDLOG_ACTIVE_LEVEL));
: }
: }
: }
:
: protected:
: with_default_setup() = default;
: };
:
: } // namespace pars::app
 |
| Generated by: llvmcov2html |