fennec
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1// =====================================================================================================================
2// fennec, a free and open source game engine
3// Copyright © 2025 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
30
31
32#ifndef FENNEC_CORE_LOGGER_H
33#define FENNEC_CORE_LOGGER_H
34
35#include <fennec/filesystem/file.h>
38
39namespace fennec
40{
41
42class logger : public singleton<logger> {
43public:
44 logger();
45 ~logger();
46
47 static void log(const cstring& str,
48 uint32_t _line = FENNEC_BUILTIN_LINE(),
49 const char* _file = FENNEC_BUILTIN_FILE()
50 ) {
51 logger& inst = instance();
52
53 if (inst._logfile.is_open()) {
54 inst._logfile.print(cstring(_file, strlen(_file)));
55 inst._logfile.printf("({}): ", _line);
56 inst._logfile.println(str);
57 }
58
59 inst._cout->print(cstring(_file, strlen(_file)));
60 inst._cout->printf("({}): ", _line);
61 inst._cout->println(str);
62 }
63
64 static void log(const string& str,
65 uint32_t _line = FENNEC_BUILTIN_LINE(),
66 const char* _file = FENNEC_BUILTIN_FILE()
67 ) {
68 logger& inst = instance();
69
70 if (inst._logfile.is_open()) {
71 inst._logfile.print(cstring(_file, strlen(_file)));
72 inst._logfile.printf("({}): ", _line);
73 inst._logfile.println(str);
74 }
75
76 inst._cout->print(cstring(_file, strlen(_file)));
77 inst._cout->printf("({}): ", _line);
78 inst._cout->println(str);
79 }
80
81private:
82 file _logfile;
83 file* _cout;
84};
85
86}
87
88#endif // FENNEC_CORE_LOGGER_H
constexpr genType log(genType x)
Returns the natural logarithm of .
Definition exponential.h:149
A header containing the definition for a container with multiple values of differing types.