quill
Filter.h
1 
7 #pragma once
8 
9 #include "quill/core/Attributes.h"
10 #include "quill/core/LogLevel.h"
11 
12 #include <cstdint>
13 #include <string>
14 #include <string_view>
15 #include <utility>
16 
17 QUILL_BEGIN_NAMESPACE
18 
20 class MacroMetadata;
21 
26 class Filter
27 {
28 public:
33  explicit Filter(std::string filter_name) : _filter_name(std::move(filter_name)) {}
34 
38  virtual ~Filter() = default;
39 
54  QUILL_NODISCARD virtual bool filter(MacroMetadata const* log_metadata, uint64_t log_timestamp,
55  std::string_view thread_id, std::string_view thread_name,
56  std::string_view logger_name, LogLevel log_level, std::string_view log_message,
57  std::string_view log_statement) noexcept = 0;
58 
63  QUILL_NODISCARD virtual std::string const& get_filter_name() const noexcept
64  {
65  return _filter_name;
66  }
67 
68 private:
69  std::string _filter_name;
70 };
71 
72 QUILL_END_NAMESPACE
virtual QUILL_NODISCARD bool filter(MacroMetadata const *log_metadata, uint64_t log_timestamp, std::string_view thread_id, std::string_view thread_name, std::string_view logger_name, LogLevel log_level, std::string_view log_message, std::string_view log_statement) noexcept=0
Filters a log message.
virtual ~Filter()=default
Destructor.
Definition: format.h:126
Captures and stores information about a logging event in compile time.
Definition: MacroMetadata.h:22
Base filter class.
Definition: Filter.h:26
Filter(std::string filter_name)
Constructor.
Definition: Filter.h:33
virtual QUILL_NODISCARD std::string const & get_filter_name() const noexcept
Gets the name of the filter.
Definition: Filter.h:63