element.cpp 635 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "log.h"
  2. #include "element.h"
  3. #include <utility>
  4. TLogElement::TLogElement(const TLog* parent)
  5. : Parent_(parent)
  6. , Priority_(Parent_->DefaultPriority())
  7. {
  8. Reset();
  9. }
  10. TLogElement::TLogElement(const TLog* parent, ELogPriority priority)
  11. : Parent_(parent)
  12. , Priority_(priority)
  13. {
  14. Reset();
  15. }
  16. TLogElement::~TLogElement() {
  17. try {
  18. Finish();
  19. } catch (...) {
  20. }
  21. }
  22. void TLogElement::DoFlush() {
  23. if (IsNull()) {
  24. return;
  25. }
  26. const size_t filled = Filled();
  27. if (filled) {
  28. Parent_->Write(Priority_, Data(), filled, std::move(Context_));
  29. Reset();
  30. }
  31. }