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
50void warn(const std::string&);
51
52#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
53template <class... Args> void warn(std::format_string<Args...> format, Args&&... args) {
54 return warn(std::format(std::move(format), std::forward<Args>(args)...));
55}
56#else
57template <class... Args> void warn(Args&&...) {}
58#endif
59
60void error(const std::string&);
61
62#if __has_include(<format>) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000)
63template <class... Args> void error(std::format_string<Args...> format, Args&&... args) {
64 return error(std::format(std::move(format), std::forward<Args>(args)...));
65}
66#else
67template <class... Args> void error(Args&&...) {}
68#endif
69
70} // namespace jngl
Contains jngl::Vec2 class.
Two-dimensional vector.
Definition Vec2.hpp:36
T format(T... args)
JNGL's main namespace.
void debug(const std::string &)
Print a log message only in debug builds (i.e. when NDEBUG is not defined)