simdjson  3.11.0
Ridiculously Fast JSON
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 
8 namespace simdjson {
9 namespace SIMDJSON_IMPLEMENTATION {
10 namespace 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.
15 namespace logger {
16 
17 enum 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).
31 static inline void log_headers() noexcept;
32 // If args are provided, title will be treated as format string
33 template <typename... Args>
34 static 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;
35 template <typename... Args>
36 static 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;
37 static inline void log_event(const json_iterator &iter, const char *type, std::string_view detail="", int delta=0, int depth_delta=0) noexcept;
38 static inline void log_value(const json_iterator &iter, token_position index, depth_t depth, const char *type, std::string_view detail="") noexcept;
39 static inline void log_value(const json_iterator &iter, const char *type, std::string_view detail="", int delta=-1, int depth_delta=0) noexcept;
40 static inline void log_start_value(const json_iterator &iter, token_position index, depth_t depth, const char *type, std::string_view detail="") noexcept;
41 static inline void log_start_value(const json_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
42 static inline void log_end_value(const json_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
43 
44 static inline void log_error(const json_iterator &iter, token_position index, depth_t depth, const char *error, const char *detail="") noexcept;
45 static inline void log_error(const json_iterator &iter, const char *error, const char *detail="", int delta=-1, int depth_delta=0) noexcept;
46 
47 static inline void log_event(const value_iterator &iter, const char *type, std::string_view detail="", int delta=0, int depth_delta=0) noexcept;
48 static inline void log_value(const value_iterator &iter, const char *type, std::string_view detail="", int delta=-1, int depth_delta=0) noexcept;
49 static inline void log_start_value(const value_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
50 static inline void log_end_value(const value_iterator &iter, const char *type, int delta=-1, int depth_delta=0) noexcept;
51 static 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