ChainCLI
A modern C++20 command-line interface library
Loading...
Searching...
No Matches
loglevel.h
1
/*
2
* Copyright 2025 Dominik Czekai
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
#include <string_view>
19
20
namespace
cli::logging
21
{
22
24
enum class
LogLevel
25
{
26
TRACE = 0,
// most detailed, prints internal logs of the library as well
27
VERBOSE,
// very detailed information for inspection/development
28
DEBUG,
// general debug information
29
INFO,
// general information
30
SUCCESS,
// report a success
31
WARNING,
// something unwanted happened, but the program can handle it
32
ERROR,
// a serious error occurred/ something failed
33
};
34
35
inline
std::string_view toString(LogLevel level)
36
{
37
switch
(level)
38
{
39
using
enum cli::logging::LogLevel;
40
case
TRACE:
41
return
"TRACE"
;
42
case
VERBOSE:
43
return
"VERBOSE"
;
44
case
DEBUG:
45
return
"DEBUG"
;
46
case
SUCCESS:
47
return
"DETAIL"
;
48
case
INFO:
49
return
"INFO"
;
50
case
WARNING:
51
return
"WARNING"
;
52
case
ERROR:
53
return
"ERROR"
;
54
}
55
return
"UNKNOWN"
;
56
}
57
58
}
// namespace cli::logging
src
chaincli
logging
loglevel.h
Generated by
1.9.8