aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger
diff options
context:
space:
mode:
authorAlexey Salmin <alexey.salmin@gmail.com>2022-02-10 16:49:37 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:37 +0300
commit3c5b1607b38f637d2f3313791ed25c2e080d2647 (patch)
tree99be7b96e7c66612fbca94331100ef3b5fedcb88 /library/cpp/logger
parentde89752358147d7b25ef59a85b431bb564068a49 (diff)
downloadydb-3c5b1607b38f637d2f3313791ed25c2e080d2647.tar.gz
Restoring authorship annotation for Alexey Salmin <alexey.salmin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/logger')
-rw-r--r--library/cpp/logger/global/rty_formater.cpp76
-rw-r--r--library/cpp/logger/global/rty_formater.h46
-rw-r--r--library/cpp/logger/global/rty_formater_ut.cpp40
-rw-r--r--library/cpp/logger/global/ut/ya.make26
4 files changed, 94 insertions, 94 deletions
diff --git a/library/cpp/logger/global/rty_formater.cpp b/library/cpp/logger/global/rty_formater.cpp
index 305f8470c5..cce0070dcb 100644
--- a/library/cpp/logger/global/rty_formater.cpp
+++ b/library/cpp/logger/global/rty_formater.cpp
@@ -1,53 +1,53 @@
#include "rty_formater.h"
#include <util/datetime/base.h>
-#include <util/datetime/systime.h>
+#include <util/datetime/systime.h>
#include <util/stream/str.h>
#include <util/stream/printf.h>
#include <util/system/mem_info.h>
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
#include <inttypes.h>
-#include <cstdio>
-
-namespace {
- constexpr size_t LocalTimeSBufferSize = sizeof("2017-07-24 12:20:34.313 +0300");
-
- size_t PrintLocalTimeS(const TInstant instant, char* const begin, const char* const end) {
- Y_VERIFY(static_cast<size_t>(end - begin) >= LocalTimeSBufferSize);
+#include <cstdio>
+namespace {
+ constexpr size_t LocalTimeSBufferSize = sizeof("2017-07-24 12:20:34.313 +0300");
+
+ size_t PrintLocalTimeS(const TInstant instant, char* const begin, const char* const end) {
+ Y_VERIFY(static_cast<size_t>(end - begin) >= LocalTimeSBufferSize);
+
struct tm tm;
- instant.LocalTime(&tm);
-
- // both stftime and sprintf exclude the terminating null byte from the return value
+ instant.LocalTime(&tm);
+
+ // both stftime and sprintf exclude the terminating null byte from the return value
char* pos = begin;
- pos += strftime(pos, end - pos, "%Y-%m-%d %H:%M:%S.", &tm);
- pos += sprintf(pos, "%03" PRIu32, instant.MilliSecondsOfSecond());
- pos += strftime(pos, end - pos, " %z", &tm);
- Y_VERIFY(LocalTimeSBufferSize - 1 == pos - begin); // together with Y_VERIFY above this also implies pos<=end
- return (pos - begin);
+ pos += strftime(pos, end - pos, "%Y-%m-%d %H:%M:%S.", &tm);
+ pos += sprintf(pos, "%03" PRIu32, instant.MilliSecondsOfSecond());
+ pos += strftime(pos, end - pos, " %z", &tm);
+ Y_VERIFY(LocalTimeSBufferSize - 1 == pos - begin); // together with Y_VERIFY above this also implies pos<=end
+ return (pos - begin);
}
-}
+}
-namespace NLoggingImpl {
+namespace NLoggingImpl {
IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS) {
- char buffer[LocalTimeSBufferSize];
- size_t len = PrintLocalTimeS(localTimeS.GetInstant(), buffer, buffer + sizeof(buffer));
- out.Write(buffer, len);
- return out;
- }
-
- TLocalTimeS::operator TString() const {
- TString res;
- res.reserve(LocalTimeSBufferSize);
- res.ReserveAndResize(PrintLocalTimeS(Instant, res.begin(), res.begin() + res.capacity()));
- return res;
- }
-
- TString TLocalTimeS::operator+(const TStringBuf right) const {
- TString res(*this);
- res += right;
- return res;
- }
-
+ char buffer[LocalTimeSBufferSize];
+ size_t len = PrintLocalTimeS(localTimeS.GetInstant(), buffer, buffer + sizeof(buffer));
+ out.Write(buffer, len);
+ return out;
+ }
+
+ TLocalTimeS::operator TString() const {
+ TString res;
+ res.reserve(LocalTimeSBufferSize);
+ res.ReserveAndResize(PrintLocalTimeS(Instant, res.begin(), res.begin() + res.capacity()));
+ return res;
+ }
+
+ TString TLocalTimeS::operator+(const TStringBuf right) const {
+ TString res(*this);
+ res += right;
+ return res;
+ }
+
TStringBuf StripFileName(TStringBuf string) {
return string.RNextTok(LOCSLASH_C);
}
diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h
index 6532e1d769..637e5ae1a1 100644
--- a/library/cpp/logger/global/rty_formater.h
+++ b/library/cpp/logger/global/rty_formater.h
@@ -16,30 +16,30 @@ public:
ILoggerFormatter* CreateRtyLoggerFormatter();
namespace NLoggingImpl {
- class TLocalTimeS {
- public:
- TLocalTimeS(TInstant instant = TInstant::Now())
- : Instant(instant)
- {
- }
-
- TInstant GetInstant() const {
- return Instant;
- }
-
- operator TString() const;
- TString operator+(TStringBuf right) const;
-
- private:
- TInstant Instant;
- };
-
+ class TLocalTimeS {
+ public:
+ TLocalTimeS(TInstant instant = TInstant::Now())
+ : Instant(instant)
+ {
+ }
+
+ TInstant GetInstant() const {
+ return Instant;
+ }
+
+ operator TString() const;
+ TString operator+(TStringBuf right) const;
+
+ private:
+ TInstant Instant;
+ };
+
IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS);
-
- inline TLocalTimeS GetLocalTimeS() {
- return TLocalTimeS();
- }
-
+
+ inline TLocalTimeS GetLocalTimeS() {
+ return TLocalTimeS();
+ }
+
TString GetSystemResources();
TString PrintSystemResources(const NMemInfo::TMemInfo& info);
diff --git a/library/cpp/logger/global/rty_formater_ut.cpp b/library/cpp/logger/global/rty_formater_ut.cpp
index 551a97c5bf..af1a8a861a 100644
--- a/library/cpp/logger/global/rty_formater_ut.cpp
+++ b/library/cpp/logger/global/rty_formater_ut.cpp
@@ -1,31 +1,31 @@
-#include "rty_formater.h"
-
+#include "rty_formater.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-namespace {
- const TStringBuf SampleISO8601("2017-07-25T19:26:09.894000+03:00");
- const TStringBuf SampleRtyLog("2017-07-25 19:26:09.894 +0300");
-}
-
+
+namespace {
+ const TStringBuf SampleISO8601("2017-07-25T19:26:09.894000+03:00");
+ const TStringBuf SampleRtyLog("2017-07-25 19:26:09.894 +0300");
+}
+
Y_UNIT_TEST_SUITE(NLoggingImplTest) {
Y_UNIT_TEST(TestTLocalTimeSToStream) {
NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
- TStringStream ss;
- ss << lt;
- UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog);
- }
+ TStringStream ss;
+ ss << lt;
+ UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog);
+ }
Y_UNIT_TEST(TestTLocalTimeSToString) {
NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
- UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog);
- }
+ UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog);
+ }
Y_UNIT_TEST(TestTLocalTimeSAddLeft) {
NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
- TStringBuf suffix("suffix");
- UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix);
- }
+ TStringBuf suffix("suffix");
+ UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix);
+ }
Y_UNIT_TEST(TestTLocalTimeSAddRight) {
NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
- TString prefix("prefix");
+ TString prefix("prefix");
UNIT_ASSERT_EQUAL(prefix + lt, prefix + SampleRtyLog);
- }
-}
+ }
+}
diff --git a/library/cpp/logger/global/ut/ya.make b/library/cpp/logger/global/ut/ya.make
index 8aea38906f..777c4ba22b 100644
--- a/library/cpp/logger/global/ut/ya.make
+++ b/library/cpp/logger/global/ut/ya.make
@@ -1,15 +1,15 @@
-UNITTEST()
-
-OWNER(salmin)
-
-PEERDIR(
+UNITTEST()
+
+OWNER(salmin)
+
+PEERDIR(
library/cpp/logger/global
-)
-
+)
+
SRCDIR(library/cpp/logger/global)
-
-SRCS(
- rty_formater_ut.cpp
-)
-
-END()
+
+SRCS(
+ rty_formater_ut.cpp
+)
+
+END()