aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger/log.h
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:48 +0300
commit9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/logger/log.h
parent8cbc307de0221f84c80c42dcbe07d40727537e2c (diff)
downloadydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/logger/log.h')
-rw-r--r--library/cpp/logger/log.h122
1 files changed, 61 insertions, 61 deletions
diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h
index e0d9e8998f..8be984ccc8 100644
--- a/library/cpp/logger/log.h
+++ b/library/cpp/logger/log.h
@@ -14,81 +14,81 @@
using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>;
-// Logging facilities interface.
-//
-// ```cpp
-// TLog base;
-// ...
-// auto log = base;
-// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) {
-// return TStringBuilder() << "reqid=" << reqId << "; " << msg;
-// });
-//
-// log.Write(TLOG_INFO, "begin");
-// HandleRequest(...);
-// log.Write(TLOG_INFO, "end");
-// ```
-//
-// Users are encouraged to copy `TLog` instance.
+// Logging facilities interface.
+//
+// ```cpp
+// TLog base;
+// ...
+// auto log = base;
+// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) {
+// return TStringBuilder() << "reqid=" << reqId << "; " << msg;
+// });
+//
+// log.Write(TLOG_INFO, "begin");
+// HandleRequest(...);
+// log.Write(TLOG_INFO, "end");
+// ```
+//
+// Users are encouraged to copy `TLog` instance.
class TLog {
public:
- // Construct empty logger all writes will be spilled.
+ // Construct empty logger all writes will be spilled.
TLog();
- // Construct file logger.
+ // Construct file logger.
TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY);
- // Construct any type of logger
+ // Construct any type of logger
TLog(THolder<TLogBackend> backend);
- TLog(const TLog&);
- TLog(TLog&&);
+ TLog(const TLog&);
+ TLog(TLog&&);
~TLog();
- TLog& operator=(const TLog&);
- TLog& operator=(TLog&&);
+ TLog& operator=(const TLog&);
+ TLog& operator=(TLog&&);
- // Change underlying backend.
- // NOTE: not thread safe.
+ // Change underlying backend.
+ // NOTE: not thread safe.
void ResetBackend(THolder<TLogBackend> backend) noexcept;
- // Reset underlying backend, `IsNullLog()` will return `true` after this call.
- // NOTE: not thread safe.
+ // Reset underlying backend, `IsNullLog()` will return `true` after this call.
+ // NOTE: not thread safe.
THolder<TLogBackend> ReleaseBackend() noexcept;
- // Check if underlying backend is defined and is not null.
- // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`.
+ // Check if underlying backend is defined and is not null.
+ // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`.
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()`.
+ // 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;
- // Write message to the log, but pass the message in a c-style.
+ // 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.
+
+ // 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;
-
- // Call `ReopenLog()` of the underlying backend.
+
+ // Call `ReopenLog()` of the underlying backend.
void ReopenLog();
- // Call `ReopenLogNoFlush()` of the underlying backend.
+ // Call `ReopenLogNoFlush()` of the underlying backend.
void ReopenLogNoFlush();
- // Call `QueueSize()` of the underlying backend.
+ // Call `QueueSize()` of the underlying backend.
size_t BackEndQueueSize() const;
- // Set log default priority.
- // NOTE: not thread safe.
+ // Set log default priority.
+ // NOTE: not thread safe.
void SetDefaultPriority(ELogPriority priority) noexcept;
- // Get default priority
+ // Get default priority
ELogPriority DefaultPriority() const noexcept;
- // Call `FiltrationLevel()` of the underlying backend.
+ // Call `FiltrationLevel()` of the underlying backend.
ELogPriority FiltrationLevel() const noexcept;
- // Set current log formatter.
- void SetFormatter(TLogFormatter formatter) noexcept;
-
+ // Set current log formatter.
+ void SetFormatter(TLogFormatter formatter) noexcept;
+
template <class T>
inline TLogElement operator<<(const T& t) const {
TLogElement ret(this);
@@ -96,18 +96,18 @@ public:
return ret;
}
-public:
- // These methods are deprecated and present here only for compatibility reasons (for 13 years
- // already ...). Do not use them.
- bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY);
- bool IsOpen() const noexcept;
- void AddLogVAList(const char* format, va_list lst);
- void CloseLog();
-
+public:
+ // These methods are deprecated and present here only for compatibility reasons (for 13 years
+ // already ...). Do not use them.
+ bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY);
+ bool IsOpen() const noexcept;
+ void AddLogVAList(const char* format, va_list lst);
+ void CloseLog();
+
private:
class TImpl;
- TIntrusivePtr<TImpl> Impl_;
- TLogFormatter Formatter_;
+ TIntrusivePtr<TImpl> Impl_;
+ TLogFormatter Formatter_;
};
THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, bool threaded = false);