StormByte-Logger 2.0.0
C++26 logger module of the StormByte suite
 
Loading...
Searching...
No Matches
typedefs.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Logger.
5 *
6 * StormByte-Logger original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Logger source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository (including everything under
22 * thirdparty/, and in particular the bundled StormByte-String tree and
23 * the StormByte Base tree it vendors), which remains under its own license.
24 *
25 * Neither license grants any patent rights. Any patent licenses required
26 * to use this software or third-party components must be obtained separately
27 * from the patent holders.
28 *
29 * StormByte-Logger is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public License
35 * version 3 along with StormByte-Logger. If not, see
36 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
37 *
38 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
39 */
40
41#pragma once
42
44
45#include <ostream>
46
51namespace StormByte::Logger {
58 enum class STORMBYTE_LOGGER_PUBLIC Color : unsigned char {
59 Default,
60 Black,
61 Red,
62 Green,
63 Yellow,
64 Blue,
65 Magenta,
66 Cyan,
67 Gray,
68 White,
70 BrightRed,
77 };
78
87 enum class STORMBYTE_LOGGER_PUBLIC Level : unsigned short {
88 LowLevel = 0,
89 Debug,
90 Warning,
91 Notice,
92 Info,
93 Error,
94 Fatal
95 };
96
102 constexpr static const char* LevelToString(const Level& l) noexcept {
103 switch (l) {
104 case Level::LowLevel: return "LowLevel";
105 case Level::Debug: return "Debug";
106 case Level::Warning: return "Warning";
107 case Level::Notice: return "Notice";
108 case Level::Info: return "Info";
109 case Level::Error: return "Error";
110 case Level::Fatal: return "Fatal";
111 default: return "Error";
112 }
113 }
114
120 using SinkWrite = void (*)(void* context, const char* data, std::size_t size);
121
128 using SinkManip = void (*)(void* context, std::ostream& (*manip)(std::ostream&));
129}
Logger module of the StormByte suite.
void(*)(void *context, std::ostream &(*manip)(std::ostream &)) SinkManip
Caller-side application of an std::ostream manipulator.
Definition typedefs.hxx:128
Level
Severity levels used by the logger.
Definition typedefs.hxx:87
@ Warning
Recoverable problems.
@ Notice
Significant normal events.
@ Info
Informational messages.
@ Fatal
Unrecoverable errors.
@ Error
Error conditions.
@ Debug
Debug information.
@ LowLevel
Verbose diagnostics.
Color
ANSI foreground colors supported by the logger.
Definition typedefs.hxx:58
@ Cyan
Standard cyan foreground.
@ White
Standard white foreground.
@ BrightBlue
Bright blue foreground.
@ BrightRed
Bright red foreground.
@ BrightWhite
Bright white foreground.
@ BrightMagenta
Bright magenta foreground.
@ Yellow
Standard yellow foreground.
@ Default
No ANSI sequence; preserve the terminal's current color.
@ BrightYellow
Bright yellow foreground.
@ BrightBlack
Bright black foreground.
@ Blue
Standard blue foreground.
@ Gray
Bright black/gray foreground.
@ BrightGreen
Bright green foreground.
@ Magenta
Standard magenta foreground.
@ BrightCyan
Bright cyan foreground.
@ Green
Standard green foreground.
@ Black
Standard black foreground.
@ Red
Standard red foreground.
static constexpr const char * LevelToString(const Level &l) noexcept
Convert a Level to a short name.
Definition typedefs.hxx:102
void(*)(void *context, const char *data, std::size_t size) SinkWrite
Caller-side write of raw bytes into the sink.
Definition typedefs.hxx:120
#define STORMBYTE_LOGGER_PUBLIC
Definition visibility.h:53