blob: 5355fa4493d08db563e2f569ab45ef646100f3c3 (
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
|
#pragma once
#include "priority.h"
#include "record.h"
#include "backend.h"
#include <util/generic/ptr.h>
class TFilteredLogBackend: public TLogBackend {
THolder<TLogBackend> Backend;
ELogPriority Level;
public:
TFilteredLogBackend(THolder<TLogBackend>&& t, ELogPriority level = LOG_MAX_PRIORITY) noexcept
: Backend(std::move(t))
, Level(level)
{
}
ELogPriority FiltrationLevel() const override {
return Level;
}
void ReopenLog() override {
Backend->ReopenLog();
}
void WriteData(const TLogRecord& rec) override {
if (rec.Priority <= (ELogPriority)Level) {
Backend->WriteData(rec);
}
}
};
|