GCC Code Coverage Report


Directory: src/oiseau/
File: src/oiseau/utils/logging.cpp
Date: 2025-05-24 01:28:39
Exec Total Coverage
Lines: 0 11 0.0%
Functions: 0 2 0.0%
Branches: 0 12 0.0%

Line Branch Exec Source
1 // Copyright (C) 2025 Tiago V. L. Amorim (@tiagovla)
2 //
3 // This file is part of oiseau (https://github.com/tiagovla/oiseau)
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6
7 #include "oiseau/utils/logging.hpp"
8
9 #include <spdlog/pattern_formatter.h>
10
11 #include <memory>
12
13 #include "spdlog/cfg/argv.h"
14 #include "spdlog/common.h"
15 #include "spdlog/logger.h"
16 #include "spdlog/sinks/stdout_color_sinks.h"
17 #include "spdlog/spdlog.h"
18
19 namespace oiseau::logging {
20
21 static std::shared_ptr<spdlog::logger> default_logger;
22
23 void set_verbosity(Verbosity level) {
24 spdlog::set_level(static_cast<spdlog::level::level_enum>(level));
25 }
26
27 void init(int argc, char** argv) {
28 spdlog::cfg::load_argv_levels(argc, argv);
29
30 spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [%s:%# %!] %v");
31 if (!default_logger) {
32 default_logger = spdlog::stdout_color_mt("oiseau");
33 spdlog::set_default_logger(default_logger);
34 }
35 spdlog::set_level(spdlog::level::info);
36 }
37
38 } // namespace oiseau::logging
39