Ditto 4.13.1
 
Loading...
Searching...
No Matches
Log.hpp
1#ifndef DITTO_LOG_H
2#define DITTO_LOG_H
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 using Callback = void (*)(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 *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
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 set_minimum_log_level(LogLevel log_level)
static void set_emoji_log_level_headings_enabled(bool enabled)
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.
static void disable_log_file()
Disables logging to the previously set log file.
static bool get_emoji_log_level_headings_enabled()
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...
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...
static LogLevel get_minimum_log_level()
static bool get_logging_enabled()
static void set_logging_enabled(bool enabled)
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
LogLevel
The log levels that the Ditto SDK supports.
Definition LogLevel.hpp:9