Raito 0.1
Loading...
Searching...
No Matches
Log.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2023 Víctor Falcón Zaro
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23*/
24
25#pragma once
26#include <string>
27
28#pragma warning(push, 0)
29#include <spdlog/spdlog.h>
30#include <spdlog/fmt/ostr.h>
31#include <spdlog/fmt/fmt.h>
32#pragma warning(pop)
33
34namespace Raito::Core::Debug
35{
38 bool Initialize(bool logDumps);
39
44 void Log(const std::string& title, const std::string& msg);
45
50 void LogWarning(const std::string& title, const std::string& msg);
51
56 void LogError(const std::string& title, const std::string& msg);
57}
59#define FMT(...) fmt::format(__VA_ARGS__)
60
61#ifndef DIST
62
66 #define LOG(x, ...) Raito::Core::Debug::Log(x, FMT(__VA_ARGS__))
67
70 #define F_LOG(...) Raito::Core::Debug::Log(__FUNCTION__, FMT(__VA__ARGS__))
71
75 #define WARN(x, ...) Raito::Core::Debug::LogWarning(x, FMT(__VA_ARGS__))
76
79 #define F_WARN(...) Raito::Core::Debug::LogWarning(__FUNCTION__, FMT(__VA_ARGS__))
80
84 #define ERR(x, ...) Raito::Core::Debug::LogError(x, FMT(__VA_ARGS__))
85
88 #define F_ERR(...) Raito::Core::Debug::LogError(__FUNCTION__, FMT(__VA_ARGS__))
89
90#else
91
92 #define LOG(x, ...)
93 #define F_LOG(...)
94
95 #define WARN(x, ...)
96 #define F_WARN(...)
97
98 #define ERR(x, ...)
99 #define F_ERR(...)
100
101#endif
Definition Log.cpp:32
void LogError(const std::string &title, const std::string &msg)
Definition Log.cpp:63
bool Initialize(bool logDumps)
Definition Log.cpp:38
void LogWarning(const std::string &title, const std::string &msg)
Definition Log.cpp:59
void Log(const std::string &title, const std::string &msg)
Definition Log.cpp:55