opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <cstddef>
10#include <format>
11#include <memory>
12#include <string_view>
13
14namespace osc
15{
16 // global logging API
17 std::shared_ptr<Logger> global_default_logger();
19
21 {
23 }
24
25 inline void log_message(LogLevel level, std::string_view message)
26 {
27 global_default_logger_raw()->log_message(level, message);
28 }
29
30 template<typename... Args>
31 void log_message(LogLevel level, std::format_string<Args...> fmt, Args&&... args)
32 {
33 global_default_logger_raw()->log_message(level, fmt, std::forward<Args>(args)...);
34 }
35
36 inline void log_trace(std::string_view message)
37 {
39 }
40
41 template<typename... Args>
42 void log_trace(std::format_string<Args...> fmt, Args&&... args)
43 {
44 log_message(LogLevel::trace, fmt, std::forward<Args>(args)...);
45 }
46
47 inline void log_debug(std::string_view message)
48 {
50 }
51
52 template<typename... Args>
53 void log_debug(std::format_string<Args...> fmt, Args&&... args)
54 {
55 log_message(LogLevel::debug, fmt, std::forward<Args>(args)...);
56 }
57
58 inline void log_info(std::string_view message)
59 {
61 }
62
63 template<typename... Args>
64 void log_info(std::format_string<Args...> fmt, Args&&... args)
65 {
66 log_message(LogLevel::info, fmt, std::forward<Args>(args)...);
67 }
68
69 inline void log_warn(std::string_view message)
70 {
72 }
73
74 template<typename... Args>
75 void log_warn(std::format_string<Args...> fmt, Args&&... args)
76 {
77 log_message(LogLevel::warn, fmt, std::forward<Args>(args)...);
78 }
79
80 inline void log_error(std::string_view message)
81 {
82 log_message(LogLevel::err, message);
83 }
84
85 template<typename... Args>
86 void log_error(std::format_string<Args...> fmt, Args&&... args)
87 {
88 log_message(LogLevel::err, fmt, std::forward<Args>(args)...);
89 }
90
91 inline void log_critical(std::string_view message)
92 {
94 }
95
96 template<typename... Args>
97 void log_critical(std::format_string<Args...> fmt, Args&&... args)
98 {
99 log_message(LogLevel::critical, fmt, std::forward<Args>(args)...);
100 }
101
102 namespace detail
103 {
104 static constexpr size_t c_max_log_traceback_messages = 512;
105 }
106
110}
Definition logger.h:17
void log_message(LogLevel log_level, std::string_view message)
Definition logger.h:28
LogLevel level() const
Definition logger.h:64
Definition synchronized_value.h:18
Definition custom_decoration_generator.h:5
LogLevel log_level()
Definition log.h:20
void log_warn(std::string_view message)
Definition log.h:69
LogLevel
Definition log_level.h:11
void log_error(std::string_view message)
Definition log.h:80
void log_message(LogLevel level, std::string_view message)
Definition log.h:25
SynchronizedValue< CircularBuffer< LogMessage, detail::c_max_log_traceback_messages > > & global_get_traceback_log()
void log_info(std::string_view message)
Definition log.h:58
LogLevel global_get_traceback_level()
constexpr U to(T &&value)
Definition conversion.h:56
void log_trace(std::string_view message)
Definition log.h:36
void log_debug(std::string_view message)
Definition log.h:47
std::shared_ptr< Logger > global_default_logger()
Logger * global_default_logger_raw()
void log_critical(std::string_view message)
Definition log.h:91
void global_set_traceback_level(LogLevel)