simdjson 4.2.3
Ridiculously Fast JSON
Loading...
Searching...
No Matches
logger.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_LOGGER_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_LOGGER_H
5#include "simdjson/generic/ondemand/base.h"
6#endif // SIMDJSON_CONDITIONAL_INCLUDE
7
8namespace simdjson {
9namespace SIMDJSON_IMPLEMENTATION {
10namespace ondemand {
11
12// Logging should be free unless SIMDJSON_VERBOSE_LOGGING is set. Importantly, it is critical
13// that the call to the log functions be side-effect free. Thus, for example, you should not
14// create temporary std::string instances.
15namespace logger {
16
17enum class log_level : int32_t {
18 info = 0,
19 error = 1
20};
21
22#if SIMDJSON_VERBOSE_LOGGING
23 static constexpr const bool LOG_ENABLED = true;
24#else
25 static constexpr const bool LOG_ENABLED = false;
26#endif
27
28// We do not want these functions to be 'really inlined' since real inlining is
29// for performance purposes and if you are using the loggers, you do not care about
30// performance (or should not).
31static inline void log_headers() noexcept;
32// If args are provided, title will be treated as format string
33template <typename... Args>
34static inline void log_line(const json_iterator &iter, token_position index, depth_t depth, const char *title_prefix, const char *title, std::string_view detail, logger::log_level level, Args&&... args) noexcept;
35template <typename... Args>
36static inline void log_line(const json_iterator &iter, const char *title_prefix, const char *title, std::string_view detail, int delta, int depth_delta, logger::log_level level, Args&&... args) noexcept;
37static inline void log_event(const json_iterator &iter, const char *type, std::string_view detail="", int delta=0, int depth_delta=0) noexcept;
38static inline void log_value(const json_iterator &iter, token_position index, depth_t depth, const char *type, std::string_view detail="") noexcept;
39static inline void log_value(const json_iterator &iter, const char *type, std::string_view detail="", int delta=-1, int depth_delta=0) noexcept;
40static inline void log_start_value(const json_iterator &iter, token_position index, depth_t depth, const char *type, std::string_view detail="") noexcept;
41static inline void log_start_value(const json_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
42static inline void log_end_value(const json_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
43
44static inline void log_error(const json_iterator &iter, token_position index, depth_t depth, const char *error, const char *detail="") noexcept;
45static inline void log_error(const json_iterator &iter, const char *error, const char *detail="", int delta=-1, int depth_delta=0) noexcept;
46
47static inline void log_event(const value_iterator &iter, const char *type, std::string_view detail="", int delta=0, int depth_delta=0) noexcept;
48static inline void log_value(const value_iterator &iter, const char *type, std::string_view detail="", int delta=-1, int depth_delta=0) noexcept;
49static inline void log_start_value(const value_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
50static inline void log_end_value(const value_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
51static inline void log_error(const value_iterator &iter, const char *error, const char *detail="", int delta=-1, int depth_delta=0) noexcept;
52
53} // namespace logger
54} // namespace ondemand
55} // namespace SIMDJSON_IMPLEMENTATION
56} // namespace simdjson
57
58#endif // SIMDJSON_GENERIC_ONDEMAND_LOGGER_H
int32_t depth_t
Represents the depth of a JSON value (number of nested arrays/objects).
Definition base.h:18
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8