JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
log.hpp
Go to the documentation of this file.
1// Copyright 2024-2025 Jan Niklas Hasse <jhasse@gmail.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include "Vec2.hpp"
8
9#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
10#include <format>
11#endif
12#include <string>
13
14namespace jngl {
15
16void trace(const std::string&);
17
18#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
19template <class... Args> void trace(std::format_string<Args...> format, Args&&... args) {
20 return trace(std::format(std::move(format), std::forward<Args>(args)...));
21}
22#else
23template <class... Args> void trace(Args&&...) {}
24#endif
25
27void debug(const std::string&);
28
30void debug(Vec2);
31
32#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
33template <class... Args> void debug(std::format_string<Args...> format, Args&&... args) {
34 return debug(std::format(std::move(format), std::forward<Args>(args)...));
35}
36#else
37template <class... Args> void debug(Args&&...) {}
38#endif
39
40void info(const std::string&);
41
42#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
43template <class... Args> void info(std::format_string<Args...> format, Args&&... args) {
44 return info(std::format(std::move(format), std::forward<Args>(args)...));
45}
46#else
47template <class... Args> void info(Args&&...) {}
48#endif
49
52void log(std::string_view levelName, const std::string&);
53
54#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
55template <class... Args> void log(std::string_view levelName, std::format_string<Args...> format, Args&&... args) {
56 return log(levelName, std::format(std::move(format), std::forward<Args>(args)...));
57}
58#else
59template <class... Args> void log(Args&&...) {}
60#endif
61
62void warn(const std::string&);
63
64#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
65template <class... Args> void warn(std::format_string<Args...> format, Args&&... args) {
66 return warn(std::format(std::move(format), std::forward<Args>(args)...));
67}
68#else
69template <class... Args> void warn(Args&&...) {}
70#endif
71
72void error(const std::string&);
73
74#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
75template <class... Args> void error(std::format_string<Args...> format, Args&&... args) {
76 return error(std::format(std::move(format), std::forward<Args>(args)...));
77}
78#else
79template <class... Args> void error(Args&&...) {}
80#endif
81
97
98} // namespace jngl
Contains jngl::Vec2 class.
Two-dimensional vector.
Definition Vec2.hpp:36
T format(T... args)
T forward(T... args)
JNGL's main namespace.
std::string simpleDemangle(std::string_view mangled)
Demangle a mangled C++ type name, e.g.
void debug(const std::string &)
Print a log message only in debug builds (i.e. when NDEBUG is not defined)
void log(std::string_view levelName, const std::string &)
Same level as "info", but with custom level name.