-
Notifications
You must be signed in to change notification settings - Fork 5
/
Logger.hpp
97 lines (73 loc) · 1.65 KB
/
Logger.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Logger.hpp
*
* Created on: 2014/10/18
* Author: Dimitri Kourkoulis
* http://dimitros.be
* License: BSD 3-Clause License (see LICENSE file)
*/
#pragma once
/**
* Logging is accessed through macros so that it can be completely
* omitted if deactivated.
*/
#define LOGERROR(MESSAGE) logger->append(error, MESSAGE)
#define LOGINFO(MESSAGE) logger->append(info, MESSAGE)
#if defined(DEBUG) || defined(_DEBUG)
#define LOGDEBUG(MESSAGE) logger->append(debug, MESSAGE)
#else
#define LOGDEBUG(MESSAGE)
#endif
#include <ostream>
#include <memory>
using namespace std;
namespace small3d {
/**
* @enum LogLevel
*
* @brief Possible logging levels.
*/
enum LogLevel {
info, debug, error
};
/**
* @class Logger
*
* @brief The standard logging class for small3d.
*
*/
class Logger {
private:
ostream *logStream;
public:
/**
* @fn Logger::Logger(ostream &stream);
*
* @brief Constructor with stream for output.
*
*
* @param [in,out] stream The stream to which events will be logged.
*/
Logger(ostream &stream);
/**
* @fn Logger::~Logger();
*
* @brief Destructor.
*
*/
~Logger();
/**
* @fn void Logger::append(const LogLevel level, const string message);
*
* @brief Appends a message to the logger.
*
* @param level The logging level (debug, info, etc).
* @param message The message.
*/
void append(const LogLevel level, const string &message);
};
void initLogger();
void initLogger(ostream &stream);
void deleteLogger();
}
extern shared_ptr<small3d::Logger> logger;