DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
log_core.h
1 /*********************************************************************************************************************************************/
2 /* DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. */
3 /* Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, */
4 /* document analysis. Offline processing possible for security and confidentiality */
5 /* */
6 /* Copyright (c) SILVERCODERS Ltd, http://silvercoders.com */
7 /* Project homepage: https://github.com/docwire/docwire */
8 /* */
9 /* SPDX-License-Identifier: GPL-2.0-only OR LicenseRef-DocWire-Commercial */
10 /*********************************************************************************************************************************************/
11 
12 #ifndef DOCWIRE_LOG_CORE_H
13 #define DOCWIRE_LOG_CORE_H
14 
15 #include "core_export.h"
16 #include "serialization_base.h"
17 #include "source_location.h"
18 #include <functional>
19 #include <span>
20 #include <string>
21 #include <string_view>
22 
45 namespace docwire::log
46 {
47 
48 class DOCWIRE_CORE_EXPORT record
49 {
50 public:
51  record(source_location location, serialization::array&& context);
52  ~record();
53 
54  record(const record&) = delete;
55  record& operator=(const record&) = delete;
56 
57  source_location m_location;
58  serialization::array m_context;
59 };
60 
61 DOCWIRE_CORE_EXPORT void set_filter(const std::string& filter_spec);
62 
67 DOCWIRE_CORE_EXPORT std::string get_filter();
68 
75 DOCWIRE_CORE_EXPORT void set_sink(std::function<void(const log::record&)> callback);
76 
81 DOCWIRE_CORE_EXPORT std::function<void(const record&)> get_sink();
82 
89 
90 namespace detail
91 {
92 // This is an internal helper function for the log_entry macro.
93 DOCWIRE_CORE_EXPORT bool is_enabled(const source_location& location, std::span<const std::string_view> entry_tags);
94 DOCWIRE_CORE_EXPORT bool is_logging_enabled();
95 }
96 
97 } // namespace docwire::log
98 
99 #endif // DOCWIRE_LOG_CORE_H
Provides a modern, high-performance, and structured logging framework.
DOCWIRE_CORE_EXPORT void set_sink(std::function< void(const log::record &)> callback)
Sets the global callback function that will receive all enabled log records.
DOCWIRE_CORE_EXPORT std::function< void(const record &)> get_sink()
Gets the current log sink function.
DOCWIRE_CORE_EXPORT serialization::object create_base_metadata(source_location location)
Creates a base serialization object with common metadata.
DOCWIRE_CORE_EXPORT std::string get_filter()
Gets the current log filter specification string.
A fallback implementation of source_location for compilers that do not support std::source_location.
Represents a serialized array (list of values).
Represents a serialized object (map of string keys to values).