libkazv
Loading...
Searching...
No Matches
debug.hpp
Go to the documentation of this file.
1/*
2 * This file is part of libkazv.
3 * SPDX-FileCopyrightText: 2020 Tusooa Zhu
4 * SPDX-License-Identifier: AGPL-3.0-or-later
5 */
6
7
8#pragma once
9#include "libkazv-config.hpp"
10#include <iostream>
11#include <chrono>
12#include <ctime>
13
14#include <boost/iostreams/stream.hpp>
15
16namespace Kazv
17{
18 namespace detail
19 {
20 extern boost::iostreams::stream<boost::iostreams::null_sink> voidOutputHelper;
21
30
31 struct OutputHelper
32 {
33 std::string category;
34 OutputLevel severity;
35 OutputLevel level;
36
37 std::ostream &basicFormat() const;
38
39 template<class T>
40 std::ostream &operator<<(T &&arg) const {
41 if (severity <= level) {
42 return basicFormat() << std::forward<T>(arg);
43 } else {
44 return voidOutputHelper;
45 }
46 }
47 };
48
49 struct OutputGroup
50 {
51 std::string name;
52 OutputLevel level;
53
54 OutputHelper dbg() const;
55 OutputHelper info() const;
56 OutputHelper warn() const;
57 OutputHelper err() const;
58 };
59
60 struct OutputConfig
61 {
62 OutputConfig();
63 OutputGroup api;
64 OutputGroup base;
65 OutputGroup client;
66 OutputGroup ee;
67 OutputGroup job;
68 OutputGroup crypto;
69 };
70 }
71
72 extern const detail::OutputConfig kzo;
73}
OutputLevel
Definition debug.hpp:23
@ ERROR
Definition debug.hpp:25
@ WARNING
Definition debug.hpp:26
@ INFO
Definition debug.hpp:27
@ NONE
Definition debug.hpp:24
@ DEBUG
Definition debug.hpp:28
boost::iostreams::stream< boost::iostreams::null_sink > voidOutputHelper
Definition debug.cpp:26
Definition location.hpp:10
const detail::OutputConfig kzo
Definition debug.cpp:113