RayZaler
0.1
The free opto-mechanical simulation framework
Logger.h
1
//
2
// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU Lesser General Public License as
6
// published by the Free Software Foundation, either version 3 of the
7
// License, or (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU Lesser General Public License for more details.
13
//
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this program. If not, see
16
// <http://www.gnu.org/licenses/>
17
//
18
19
#ifndef _LIBRZ_LOGGER_H
20
#define _LIBRZ_LOGGER_H
21
22
#include "Helpers.h"
23
24
namespace
RZ {
25
enum
LogLevel {
26
LOG_ERROR,
27
LOG_WARNING,
28
LOG_INFO
29
};
30
31
class
Logger
{
32
static
Logger
*m_logger;
33
static
int
m_maxLevel;
34
35
public
:
36
// To be implemented by all loggers
37
virtual
void
logFunction(
38
LogLevel level,
39
std::string
const
&file,
40
int
line,
41
std::string
const
&message) = 0;
42
43
static
void
log(
44
LogLevel level,
45
std::string
const
&file,
46
int
line,
47
const
char
*fmt, ...);
48
49
static
void
setDefaultLogger(
Logger
*);
50
static
void
setLogLevel(
int
max);
51
};
52
53
class
StdErrLogger
:
public
Logger
{
54
bool
m_lineFeed =
true
;
55
56
public
:
57
virtual
void
logFunction(
58
LogLevel level,
59
std::string
const
&file,
60
int
line,
61
std::string
const
&message)
override
;
62
};
63
}
64
65
#define RZError(fmt, arg...) \
66
RZ::Logger::log(RZ::LOG_ERROR, __FILE__, __LINE__, fmt, ##arg)
67
#define RZWarning(fmt, arg...) \
68
RZ::Logger::log(RZ::LOG_WARNING, __FILE__, __LINE__, fmt, ##arg)
69
#define RZInfo(fmt, arg...) \
70
RZ::Logger::log(RZ::LOG_INFO, __FILE__, __LINE__, fmt, ##arg)
71
72
#endif
// _LIBRZ_LOGGER_H
RZ::Logger
Definition:
Logger.h:31
RZ::StdErrLogger
Definition:
Logger.h:53
LibRZ
include
Logger.h
Generated by
1.9.4