aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger/element.cpp
blob: ecce365f1f49a44d55826f527e36f808beb5ea87 (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
34
35
36
37
38
39
#include "log.h"
#include "element.h"

#include <utility>


TLogElement::TLogElement(const TLog* parent)
    : Parent_(parent)
    , Priority_(Parent_->DefaultPriority())
{
    Reset();
}

TLogElement::TLogElement(const TLog* parent, ELogPriority priority)
    : Parent_(parent)
    , Priority_(priority)
{
    Reset();
}

TLogElement::~TLogElement() {
    try {
        Finish();
    } catch (...) {
    }
}

void TLogElement::DoFlush() {
    if (IsNull()) {
        return;
    }

    const size_t filled = Filled();

    if (filled) {
        Parent_->Write(Priority_, Data(), filled, std::move(Context_));
        Reset();
    }
}