aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger/log.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/logger/log.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/logger/log.h')
-rw-r--r--library/cpp/logger/log.h54
1 files changed, 27 insertions, 27 deletions
diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h
index 8be984ccc8..7cb2a471f1 100644
--- a/library/cpp/logger/log.h
+++ b/library/cpp/logger/log.h
@@ -1,17 +1,17 @@
#pragma once
#include "backend.h"
-#include "element.h"
-#include "priority.h"
+#include "element.h"
+#include "priority.h"
#include "record.h"
#include "thread.h"
-
+
#include <util/generic/fwd.h>
-#include <util/generic/ptr.h>
+#include <util/generic/ptr.h>
#include <functional>
-#include <cstdarg>
-
+#include <cstdarg>
+
using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>;
// Logging facilities interface.
@@ -30,21 +30,21 @@ using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>;
// ```
//
// Users are encouraged to copy `TLog` instance.
-class TLog {
-public:
+class TLog {
+public:
// Construct empty logger all writes will be spilled.
- TLog();
+ TLog();
// Construct file logger.
TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY);
// Construct any type of logger
TLog(THolder<TLogBackend> backend);
-
+
TLog(const TLog&);
TLog(TLog&&);
- ~TLog();
+ ~TLog();
TLog& operator=(const TLog&);
TLog& operator=(TLog&&);
-
+
// Change underlying backend.
// NOTE: not thread safe.
void ResetBackend(THolder<TLogBackend> backend) noexcept;
@@ -53,30 +53,30 @@ public:
THolder<TLogBackend> ReleaseBackend() noexcept;
// Check if underlying backend is defined and is not null.
// NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`.
- bool IsNullLog() const noexcept;
-
+ bool IsNullLog() const noexcept;
+
// Write message to the log.
//
// @param[in] priority Message priority to use.
// @param[in] message Message to write.
void Write(ELogPriority priority, TStringBuf message) const;
// Write message to the log using `DefaultPriority()`.
- void Write(const char* data, size_t len) const;
+ void Write(const char* data, size_t len) const;
// Write message to the log, but pass the message in a c-style.
void Write(ELogPriority priority, const char* data, size_t len) const;
// Write message to the log in a c-like printf style.
void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const;
// Write message to the log in a c-like printf style with `DefaultPriority()` priority.
- void Y_PRINTF_FORMAT(2, 3) AddLog(const char* format, ...) const;
+ void Y_PRINTF_FORMAT(2, 3) AddLog(const char* format, ...) const;
// Call `ReopenLog()` of the underlying backend.
- void ReopenLog();
+ void ReopenLog();
// Call `ReopenLogNoFlush()` of the underlying backend.
void ReopenLogNoFlush();
// Call `QueueSize()` of the underlying backend.
size_t BackEndQueueSize() const;
-
+
// Set log default priority.
// NOTE: not thread safe.
void SetDefaultPriority(ELogPriority priority) noexcept;
@@ -89,13 +89,13 @@ public:
// Set current log formatter.
void SetFormatter(TLogFormatter formatter) noexcept;
- template <class T>
+ template <class T>
inline TLogElement operator<<(const T& t) const {
- TLogElement ret(this);
- ret << t;
- return ret;
- }
-
+ TLogElement ret(this);
+ ret << t;
+ return ret;
+ }
+
public:
// These methods are deprecated and present here only for compatibility reasons (for 13 years
// already ...). Do not use them.
@@ -104,11 +104,11 @@ public:
void AddLogVAList(const char* format, va_list lst);
void CloseLog();
-private:
- class TImpl;
+private:
+ class TImpl;
TIntrusivePtr<TImpl> Impl_;
TLogFormatter Formatter_;
-};
+};
THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, bool threaded = false);
THolder<TLogBackend> CreateFilteredOwningThreadedLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, size_t queueLen = 0);