Brenta Engine
1.2
Loading...
Searching...
No Matches
logger.hpp
1
// SPDX-License-Identifier: MIT
2
// Author: Giovanni Santini
3
// Mail: giovanni.santini@proton.me
4
// Github: @San7o
5
6
#pragma once
7
8
#include <brenta/subsystem.hpp>
9
#include <oak/oak.hpp>
10
11
#include <fstream>
12
#include <iostream>
13
#include <expected>
14
#include <string>
15
16
#define DEBUG(...) OAK_DEBUG(__VA_ARGS__);
17
#define INFO(...) OAK_INFO(__VA_ARGS__);
18
#define WARN(...) OAK_WARN(__VA_ARGS__);
19
#define ERROR(...) OAK_ERROR(__VA_ARGS__);
20
21
namespace
brenta
22
{
23
24
class
logger
:
public
subsystem
25
{
26
public
:
27
28
struct
config
;
29
class
builder
;
30
31
static
const
std::string subsystem_name;
32
static
const
config
default_config;
33
static
config
init_config;
34
35
// Subsystem interface
36
std::expected<void, subsystem::error> initialize()
override
;
37
std::expected<void, subsystem::error> terminate()
override
;
38
std::string
name
()
override
;
39
bool
is_initialized
()
override
;
40
41
// Constructors / destructors
42
logger
() =
default
;
43
~logger
() =
default
;
44
45
// Member functions
46
47
static
logger
&instance();
48
49
private
:
50
51
static
oak::level log_level;
52
static
std::string log_file;
53
static
bool
initialized;
54
55
};
56
57
struct
logger::config
58
{
59
oak::level log_level;
60
std::string log_file;
61
};
62
63
class
logger::builder
:
public
subsystem::builder
64
{
65
private
:
66
67
logger::config
conf = logger::default_config;
68
69
public
:
70
71
builder
() =
default
;
72
~builder
() =
default
;
73
74
builder
&level(oak::level log_level);
75
builder
&file(std::string out_file);
76
77
subsystem
&build();
78
};
79
80
}
// namespace brenta
brenta::logger::builder
Definition
logger.hpp:64
brenta::logger
Definition
logger.hpp:25
brenta::logger::name
std::string name() override
Returns the name of the sybsystem.
Definition
logger.cpp:64
brenta::logger::is_initialized
bool is_initialized() override
Returns true if the subsystem is initialized.
Definition
logger.cpp:69
brenta::subsystem::builder
Builder interface.
Definition
subsystem.hpp:49
brenta::subsystem
Subsystem interface.
Definition
subsystem.hpp:22
brenta::logger::config
Definition
logger.hpp:58
include
brenta
logger.hpp
Generated by
1.12.0