aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/logger/element.cpp
blob: b510fe16e117843774ee962fcb41ef1df30137d5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12

                    

                                            




                                           






                                                                   





                             


                   





                                                  
#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);
        Reset();
    }
}