Ditto 4.8.0-rc.2
Loading...
Searching...
No Matches
Log.hpp
1#ifndef _DITTO_LOG_
2#define _DITTO_LOG_
3
4#include "LogLevel.hpp"
5
6#include "dittoffi.hpp"
7
8#include <atomic>
9#include <future>
10#include <string>
11
12namespace ditto {
13
29class Log {
30public:
31 typedef void (*Callback)(LogLevel, std::string);
32
33private:
34 static std::atomic<Callback> custom_log_cb;
35 static void ffi_shimmed_cb(CLogLevel_t c_log_level, char const *c_msg);
36
37public:
38 static void e(std::string const &message);
39 static void w(std::string const &message);
40 static void i(std::string const &message);
41 static void d(std::string const &message);
42 static void v(std::string const &message);
43
44 static void process_log_message(LogLevel log_level,
45 std::string const &message);
46
53 static bool get_logging_enabled();
54
64 static void set_logging_enabled(bool enabled);
65
70
77 static void set_emoji_log_level_headings_enabled(bool enabled);
78
85 static LogLevel get_minimum_log_level();
86
96 static void set_minimum_log_level(LogLevel log_level);
97
105 static void set_log_file(std::string const &log_file_path);
106
110 static void disable_log_file();
111
120 static void set_custom_log_cb(Callback log_cb);
121
165 static std::future<uint64_t> export_to_file(std::string const &file_path);
166};
167} // namespace ditto
168
169#endif
Main singleton (global instance) to tweak the behavior of Ditto's logging infrastructure.
Definition Log.hpp:29
static void disable_log_file()
Disables logging to the previously set log file.
Definition Log.cpp:86
static void set_logging_enabled(bool enabled)
Definition Log.cpp:66
static LogLevel get_minimum_log_level()
Definition Log.cpp:75
static void set_emoji_log_level_headings_enabled(bool enabled)
Definition Log.cpp:71
static std::future< uint64_t > export_to_file(std::string const &file_path)
Exports collected logs to a compressed and JSON-encoded file on the local file system.
Definition Log.cpp:133
static bool get_logging_enabled()
Definition Log.cpp:65
static void set_log_file(std::string const &log_file_path)
Registers a file path where logs will be written to, whenever Ditto wants to issue a log (on top of e...
Definition Log.cpp:82
static void set_minimum_log_level(LogLevel log_level)
Definition Log.cpp:78
static bool get_emoji_log_level_headings_enabled()
Definition Log.cpp:68
static void set_custom_log_cb(Callback log_cb)
Registers a callback for a fully customizable way of handling log "events" from the logger (on top of...
Definition Log.cpp:99