aboutsummaryrefslogtreecommitdiffstats
path: root/logd/src/logd/empty_forwarder.h
blob: 0ee33f3e71f25474b4ee68ca5fda595c2fdf21b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "forwarder.h"
#include <vespa/vespalib/stllike/string.h>
#include <memory>

namespace logdemon {

struct Metrics;

/**
 * Class that does not forward log lines, but tracks metrics.
 *
 * Used when forwarding to logserver is turned off.
 */
class EmptyForwarder : public Forwarder {
private:
    Metrics& _metrics;
    int _badLines;

public:
    EmptyForwarder(Metrics& metrics);
    ~EmptyForwarder();

    // Implements Forwarder
    void forwardLine(std::string_view line) override;
    void flush() override {}
    int badLines() const override { return _badLines; }
    void resetBadLines() override { _badLines = 0; }
};

}