aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger/rotating_file_creator.cpp
blob: 6f71b6857369ae6d63914cab85b20ec6a31c6b07 (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
#include "rotating_file_creator.h"
#include "rotating_file.h"

THolder<TLogBackend> TRotatingFileLogBackendCreator::DoCreateLogBackend() const {
    return MakeHolder<TRotatingFileLogBackend>(Path, MaxSizeBytes, RotatedFilesCount);
}


TRotatingFileLogBackendCreator::TRotatingFileLogBackendCreator()
    : TFileLogBackendCreator("", "rotating")
{}

bool TRotatingFileLogBackendCreator::Init(const IInitContext& ctx) {
    if (!TFileLogBackendCreator::Init(ctx)) {
        return false;
    }
    ctx.GetValue("MaxSizeBytes", MaxSizeBytes);
    ctx.GetValue("RotatedFilesCount", RotatedFilesCount);
    return true;
}

ILogBackendCreator::TFactory::TRegistrator<TRotatingFileLogBackendCreator> TRotatingFileLogBackendCreator::Registrar("rotating");

void TRotatingFileLogBackendCreator::DoToJson(NJson::TJsonValue& value) const {
    TFileLogBackendCreator::DoToJson(value);
    value["MaxSizeBytes"] = MaxSizeBytes;
    value["RotatedFilesCount"] = RotatedFilesCount;
}