1
#pragma once
2

            
3
#include <cstdint>
4
#include <string>
5
#include <vector>
6

            
7
#include "envoy/access_log/access_log.h"
8
#include "envoy/runtime/runtime.h"
9

            
10
#include "source/common/access_log/access_log_impl.h"
11
#include "source/common/http/header_utility.h"
12
#include "source/common/protobuf/protobuf.h"
13

            
14
namespace Envoy {
15
namespace Extensions {
16
namespace AccessLoggers {
17
namespace Common {
18

            
19
/**
20
 * Base implementation of Accesslog::Instance handles common filter logic.
21
 */
22
class ImplBase : public AccessLog::Instance {
23
public:
24
20841
  ImplBase(AccessLog::FilterPtr filter) : filter_(std::move(filter)) {}
25

            
26
  /**
27
   * Log a completed request if the underlying AccessLog `filter_` allows it.
28
   */
29
  void log(const Formatter::Context& log_context,
30
           const StreamInfo::StreamInfo& stream_info) override;
31

            
32
private:
33
  /**
34
   * Log a completed request.
35
   * @param context supplies the necessary context to log.
36
   * @param stream_info supplies additional information about the request not
37
   * contained in the request headers.
38
   */
39
  virtual void emitLog(const Formatter::Context& context,
40
                       const StreamInfo::StreamInfo& stream_info) PURE;
41

            
42
  AccessLog::FilterPtr filter_;
43
};
44

            
45
} // namespace Common
46
} // namespace AccessLoggers
47
} // namespace Extensions
48
} // namespace Envoy