GCC Code Coverage Report


Directory: src/oiseau/
File: src/oiseau/utils/logging.cpp
Date: 2026-11-23 22:30:49
Exec Total Coverage
Lines: 11 11 100.0%
Functions: 2 2 100.0%
Branches: 6 12 50.0%

Line Branch Exec Source
1 // Copyright (C) 2026 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 6 void set_verbosity(Verbosity level) {
24 6 spdlog::set_level(static_cast<spdlog::level::level_enum>(level));
25 6 }
26
27 1 void init(int argc, char** argv) {
28 1 spdlog::cfg::load_argv_levels(argc, argv);
29
30
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [%s:%# %!] %v");
31
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 if (!default_logger) {
32
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 default_logger = spdlog::stdout_color_mt("oiseau");
33
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 spdlog::set_default_logger(default_logger);
34 }
35 1 spdlog::set_level(spdlog::level::info);
36 1 }
37
38 } // namespace oiseau::logging
39