aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors
diff options
context:
space:
mode:
authorIvan Blinkov <ivan@blinkov.ru>2022-02-10 16:47:10 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:10 +0300
commit1aeb9a455974457866f78722ad98114bafc84e8a (patch)
treee4340eaf1668684d83a0a58c36947c5def5350ad /library/cpp/actors
parentbd5ef432f5cfb1e18851381329d94665a4c22470 (diff)
downloadydb-1aeb9a455974457866f78722ad98114bafc84e8a.tar.gz
Restoring authorship annotation for Ivan Blinkov <ivan@blinkov.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/actors')
-rw-r--r--library/cpp/actors/core/log.cpp98
-rw-r--r--library/cpp/actors/core/log.h12
-rw-r--r--library/cpp/actors/core/log_settings.cpp88
-rw-r--r--library/cpp/actors/core/log_settings.h38
4 files changed, 118 insertions, 118 deletions
diff --git a/library/cpp/actors/core/log.cpp b/library/cpp/actors/core/log.cpp
index 5f63b5af58..902b19e6d9 100644
--- a/library/cpp/actors/core/log.cpp
+++ b/library/cpp/actors/core/log.cpp
@@ -166,8 +166,8 @@ namespace NActors {
TAtomic TLoggerActor::IsOverflow = 0;
- TLoggerActor::TLoggerActor(TIntrusivePtr<NLog::TSettings> settings,
- TAutoPtr<TLogBackend> logBackend,
+ TLoggerActor::TLoggerActor(TIntrusivePtr<NLog::TSettings> settings,
+ TAutoPtr<TLogBackend> logBackend,
TIntrusivePtr<NMonitoring::TDynamicCounters> counters)
: TActor(&TLoggerActor::StateFunc)
, Settings(settings)
@@ -305,7 +305,7 @@ namespace NActors {
void TLoggerActor::HandleLogComponentLevelRequest(TLogComponentLevelRequest::TPtr& ev, const NActors::TActorContext& ctx) {
Metrics->IncLevelRequests();
TString explanation;
- int code = Settings->SetLevel(ev->Get()->Priority, ev->Get()->Component, explanation);
+ int code = Settings->SetLevel(ev->Get()->Priority, ev->Get()->Component, explanation);
ctx.Send(ev->Sender, new TLogComponentLevelResponse(code, explanation));
}
@@ -370,12 +370,12 @@ namespace NActors {
const auto& params = ev->Get()->Request.GetParams();
NLog::EComponent component = NLog::InvalidComponent;
NLog::EPriority priority = NLog::PRI_DEBUG;
- NLog::EPriority samplingPriority = NLog::PRI_DEBUG;
- ui32 samplingRate = 0;
+ NLog::EPriority samplingPriority = NLog::PRI_DEBUG;
+ ui32 samplingRate = 0;
bool hasComponent = false;
bool hasPriority = false;
- bool hasSamplingPriority = false;
- bool hasSamplingRate = false;
+ bool hasSamplingPriority = false;
+ bool hasSamplingRate = false;
bool hasAllowDrop = false;
int allowDrop = 0;
if (params.Has("c")) {
@@ -388,18 +388,18 @@ namespace NActors {
hasPriority = true;
}
}
- if (params.Has("sp")) {
- int rawPriority;
- if (TryFromString(params.Get("sp"), rawPriority) && NLog::TSettings::IsValidPriority((NLog::EPriority)rawPriority)) {
- samplingPriority = (NLog::EPriority)rawPriority;
- hasSamplingPriority = true;
- }
- }
- if (params.Has("sr")) {
- if (TryFromString(params.Get("sr"), samplingRate)) {
- hasSamplingRate = true;
- }
- }
+ if (params.Has("sp")) {
+ int rawPriority;
+ if (TryFromString(params.Get("sp"), rawPriority) && NLog::TSettings::IsValidPriority((NLog::EPriority)rawPriority)) {
+ samplingPriority = (NLog::EPriority)rawPriority;
+ hasSamplingPriority = true;
+ }
+ }
+ if (params.Has("sr")) {
+ if (TryFromString(params.Get("sr"), samplingRate)) {
+ hasSamplingRate = true;
+ }
+ }
}
}
if (params.Has("allowdrop")) {
@@ -409,7 +409,7 @@ namespace NActors {
}
TStringStream str;
- if (hasComponent && !hasPriority && !hasSamplingPriority && !hasSamplingRate) {
+ if (hasComponent && !hasPriority && !hasSamplingPriority && !hasSamplingRate) {
NLog::TComponentSettings componentSettings = Settings->GetComponentSettings(component);
ui32 samplingRate = componentSettings.Raw.X.SamplingRate;
HTML(str) {
@@ -420,16 +420,16 @@ namespace NActors {
}
UL() {
LI() {
- str << "Priority: "
+ str << "Priority: "
<< NLog::PriorityToString(NLog::EPrio(componentSettings.Raw.X.Level));
}
LI() {
- str << "Sampling priority: "
+ str << "Sampling priority: "
<< NLog::PriorityToString(NLog::EPrio(componentSettings.Raw.X.SamplingLevel));
}
LI() {
- str << "Sampling rate: "
- << samplingRate;
+ str << "Sampling rate: "
+ << samplingRate;
}
}
}
@@ -443,10 +443,10 @@ namespace NActors {
UL() {
for (int p = NLog::PRI_EMERG; p <= NLog::PRI_TRACE; ++p) {
LI() {
- str << "<a href='logger?c=" << component << "&p=" << p << "'>"
+ str << "<a href='logger?c=" << component << "&p=" << p << "'>"
<< NLog::PriorityToString(NLog::EPrio(p)) << "</a>";
}
- }
+ }
}
H4() {
str << "Change sampling priority" << Endl;
@@ -454,19 +454,19 @@ namespace NActors {
UL() {
for (int p = NLog::PRI_EMERG; p <= NLog::PRI_TRACE; ++p) {
LI() {
- str << "<a href='logger?c=" << component << "&sp=" << p << "'>"
+ str << "<a href='logger?c=" << component << "&sp=" << p << "'>"
<< NLog::PriorityToString(NLog::EPrio(p)) << "</a>";
}
- }
+ }
}
H4() {
str << "Change sampling rate" << Endl;
}
- str << "<form method=\"GET\">" << Endl;
- str << "Rate: <input type=\"number\" name=\"sr\" value=\"" << samplingRate << "\"/>" << Endl;
- str << "<input type=\"hidden\" name=\"c\" value=\"" << component << "\">" << Endl;
- str << "<input class=\"btn btn-primary\" type=\"submit\" value=\"Change\"/>" << Endl;
- str << "</form>" << Endl;
+ str << "<form method=\"GET\">" << Endl;
+ str << "Rate: <input type=\"number\" name=\"sr\" value=\"" << samplingRate << "\"/>" << Endl;
+ str << "<input type=\"hidden\" name=\"c\" value=\"" << component << "\">" << Endl;
+ str << "<input class=\"btn btn-primary\" type=\"submit\" value=\"Change\"/>" << Endl;
+ str << "</form>" << Endl;
H4() {
str << "<a href='logger'>Cancel</a>" << Endl;
}
@@ -477,14 +477,14 @@ namespace NActors {
} else {
TString explanation;
if (hasComponent && hasPriority) {
- Settings->SetLevel(priority, component, explanation);
- }
- if (hasComponent && hasSamplingPriority) {
- Settings->SetSamplingLevel(samplingPriority, component, explanation);
- }
- if (hasComponent && hasSamplingRate) {
- Settings->SetSamplingRate(samplingRate, component, explanation);
+ Settings->SetLevel(priority, component, explanation);
}
+ if (hasComponent && hasSamplingPriority) {
+ Settings->SetSamplingLevel(samplingPriority, component, explanation);
+ }
+ if (hasComponent && hasSamplingRate) {
+ Settings->SetSamplingRate(samplingRate, component, explanation);
+ }
if (hasAllowDrop) {
Settings->SetAllowDrop(allowDrop);
}
@@ -544,17 +544,17 @@ namespace NActors {
<< NLog::PriorityToString(NLog::EPrio(p)) << "</a>";
}
}
- }
+ }
}
}
H4() {
str << "Change sampling rate for all components";
}
- str << "<form method=\"GET\">" << Endl;
- str << "Rate: <input type=\"number\" name=\"sr\" value=\"0\"/>" << Endl;
- str << "<input type=\"hidden\" name=\"c\" value=\"-1\">" << Endl;
- str << "<input class=\"btn btn-primary\" type=\"submit\" value=\"Change\"/>" << Endl;
- str << "</form>" << Endl;
+ str << "<form method=\"GET\">" << Endl;
+ str << "Rate: <input type=\"number\" name=\"sr\" value=\"0\"/>" << Endl;
+ str << "<input type=\"hidden\" name=\"c\" value=\"-1\">" << Endl;
+ str << "<input class=\"btn btn-primary\" type=\"submit\" value=\"Change\"/>" << Endl;
+ str << "</form>" << Endl;
H4() {
str << "Drop log entries in case of overflow: "
<< (Settings->AllowDrop ? "Enabled" : "Disabled");
@@ -579,7 +579,7 @@ namespace NActors {
const auto logPrio = ::ELogPriority(ui16(priority));
char buf[TimeBufSize];
- switch (Settings->Format) {
+ switch (Settings->Format) {
case NActors::NLog::TSettings::PLAIN_FULL_FORMAT: {
TStringBuilder logRecord;
if (Settings->UseLocalTimestamps) {
@@ -633,7 +633,7 @@ namespace NActors {
LogBackend->WriteData(
TLogRecord(logPrio, logRecord.data(), logRecord.size()));
} break;
- }
+ }
return true;
} catch (...) {
@@ -658,7 +658,7 @@ namespace NActors {
}
TAutoPtr<TLogBackend> CreateSysLogBackend(const TString& ident,
- bool logPError, bool logCons) {
+ bool logPError, bool logCons) {
int flags = 0;
if (logPError)
flags |= TSysLogBackend::LogPerror;
diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h
index c11a7cf3c1..0bebd209e6 100644
--- a/library/cpp/actors/core/log.h
+++ b/library/cpp/actors/core/log.h
@@ -52,7 +52,7 @@
#define LOG_LOG(actorCtxOrSystem, priority, component, ...) LOG_LOG_SAMPLED_BY(actorCtxOrSystem, priority, component, 0ull, __VA_ARGS__)
#define LOG_LOG_S(actorCtxOrSystem, priority, component, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, priority, component, 0ull, stream)
-
+
// use these macros for logging via actor system or actor context
#define LOG_EMERG(actorCtxOrSystem, component, ...) LOG_LOG(actorCtxOrSystem, NActors::NLog::PRI_EMERG, component, __VA_ARGS__)
#define LOG_ALERT(actorCtxOrSystem, component, ...) LOG_LOG(actorCtxOrSystem, NActors::NLog::PRI_ALERT, component, __VA_ARGS__)
@@ -89,11 +89,11 @@
#define LOG_CRIT_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_CRIT, component, sampleBy, stream)
#define LOG_ERROR_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_ERROR, component, sampleBy, stream)
#define LOG_WARN_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_WARN, component, sampleBy, stream)
-#define LOG_NOTICE_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_NOTICE, component, sampleBy, stream)
+#define LOG_NOTICE_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_NOTICE, component, sampleBy, stream)
#define LOG_INFO_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_INFO, component, sampleBy, stream)
#define LOG_DEBUG_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_DEBUG, component, sampleBy, stream)
#define LOG_TRACE_S_SAMPLED_BY(actorCtxOrSystem, component, sampleBy, stream) LOG_LOG_S_SAMPLED_BY(actorCtxOrSystem, NActors::NLog::PRI_TRACE, component, sampleBy, stream)
-
+
// Log Throttling
#define LOG_LOG_THROTTLE(throttler, actorCtxOrSystem, priority, component, ...) \
do { \
@@ -196,8 +196,8 @@ namespace NActors {
return IActor::LOG_ACTOR;
}
- TLoggerActor(TIntrusivePtr<NLog::TSettings> settings,
- TAutoPtr<TLogBackend> logBackend,
+ TLoggerActor(TIntrusivePtr<NLog::TSettings> settings,
+ TAutoPtr<TLogBackend> logBackend,
TIntrusivePtr<NMonitoring::TDynamicCounters> counters);
TLoggerActor(TIntrusivePtr<NLog::TSettings> settings,
std::shared_ptr<TLogBackend> logBackend,
@@ -295,7 +295,7 @@ namespace NActors {
// SYSLOG BACKEND
////////////////////////////////////////////////////////////////////////////////
TAutoPtr<TLogBackend> CreateSysLogBackend(const TString& ident,
- bool logPError, bool logCons);
+ bool logPError, bool logCons);
TAutoPtr<TLogBackend> CreateStderrBackend();
TAutoPtr<TLogBackend> CreateFileBackend(const TString& fileName);
TAutoPtr<TLogBackend> CreateNullBackend();
diff --git a/library/cpp/actors/core/log_settings.cpp b/library/cpp/actors/core/log_settings.cpp
index f52f2fc5d2..4868521fb7 100644
--- a/library/cpp/actors/core/log_settings.cpp
+++ b/library/cpp/actors/core/log_settings.cpp
@@ -17,12 +17,12 @@ namespace NActors {
, MaxVal(0)
, Mask(0)
, DefPriority(defPriority)
- , DefSamplingPriority(defSamplingPriority)
- , DefSamplingRate(defSamplingRate)
+ , DefSamplingPriority(defSamplingPriority)
+ , DefSamplingRate(defSamplingRate)
, UseLocalTimestamps(false)
- , Format(PLAIN_FULL_FORMAT)
- , ShortHostName("")
- , ClusterName("")
+ , Format(PLAIN_FULL_FORMAT)
+ , ShortHostName("")
+ , ClusterName("")
{
Append(minVal, maxVal, func);
}
@@ -39,14 +39,14 @@ namespace NActors {
, MaxVal(0)
, Mask(0)
, DefPriority(defPriority)
- , DefSamplingPriority(defSamplingPriority)
- , DefSamplingRate(defSamplingRate)
+ , DefSamplingPriority(defSamplingPriority)
+ , DefSamplingRate(defSamplingRate)
, UseLocalTimestamps(false)
- , Format(PLAIN_FULL_FORMAT)
- , ShortHostName("")
- , ClusterName("")
- {
- }
+ , Format(PLAIN_FULL_FORMAT)
+ , ShortHostName("")
+ , ClusterName("")
+ {
+ }
void TSettings::Append(EComponent minVal, EComponent maxVal, EComponentToStringFunc func) {
Y_VERIFY(minVal >= 0, "NLog::TSettings: minVal must be non-negative");
@@ -87,17 +87,17 @@ namespace NActors {
}
}
- int TSettings::SetLevelImpl(
+ int TSettings::SetLevelImpl(
const TString& name, bool isSampling,
EPriority priority, EComponent component, TString& explanation) {
TString titleName(name);
- titleName.to_title();
-
+ titleName.to_title();
+
// check priority
if (!IsValidPriority(priority)) {
- TStringStream str;
- str << "Invalid " << name;
- explanation = str.Str();
+ TStringStream str;
+ str << "Invalid " << name;
+ explanation = str.Str();
return 1;
}
@@ -113,9 +113,9 @@ namespace NActors {
}
TStringStream str;
-
- str << titleName
- << " for all components has been changed to "
+
+ str << titleName
+ << " for all components has been changed to "
<< PriorityToString(EPrio(priority));
explanation = str.Str();
return 0;
@@ -135,7 +135,7 @@ namespace NActors {
}
AtomicSet(ComponentInfo[component], settings.Raw.Data);
TStringStream str;
- str << titleName << " for the component " << ComponentNames[component]
+ str << titleName << " for the component " << ComponentNames[component]
<< " has been changed from " << PriorityToString(EPrio(oldPriority))
<< " to " << PriorityToString(EPrio(priority));
explanation = str.Str();
@@ -146,41 +146,41 @@ namespace NActors {
int TSettings::SetLevel(EPriority priority, EComponent component, TString& explanation) {
return SetLevelImpl("priority", false,
priority, component, explanation);
- }
-
+ }
+
int TSettings::SetSamplingLevel(EPriority priority, EComponent component, TString& explanation) {
return SetLevelImpl("sampling priority", true,
priority, component, explanation);
- }
-
+ }
+
int TSettings::SetSamplingRate(ui32 sampling, EComponent component, TString& explanation) {
- if (component == InvalidComponent) {
- for (int i = 0; i < Mask + 1; i++) {
+ if (component == InvalidComponent) {
+ for (int i = 0; i < Mask + 1; i++) {
TComponentSettings settings = AtomicGet(ComponentInfo[i]);
settings.Raw.X.SamplingRate = sampling;
AtomicSet(ComponentInfo[i], settings.Raw.Data);
- }
- TStringStream str;
- str << "Sampling rate for all components has been changed to " << sampling;
- explanation = str.Str();
- } else {
- if (!IsValidComponent(component)) {
- explanation = "Invalid component";
- return 1;
- }
+ }
+ TStringStream str;
+ str << "Sampling rate for all components has been changed to " << sampling;
+ explanation = str.Str();
+ } else {
+ if (!IsValidComponent(component)) {
+ explanation = "Invalid component";
+ return 1;
+ }
TComponentSettings settings = AtomicGet(ComponentInfo[component]);
ui32 oldSampling = settings.Raw.X.SamplingRate;
settings.Raw.X.SamplingRate = sampling;
AtomicSet(ComponentInfo[component], settings.Raw.Data);
- TStringStream str;
- str << "Sampling rate for the component " << ComponentNames[component]
+ TStringStream str;
+ str << "Sampling rate for the component " << ComponentNames[component]
<< " has been changed from " << oldSampling
<< " to " << sampling;
- explanation = str.Str();
- }
- return 0;
- }
-
+ explanation = str.Str();
+ }
+ return 0;
+ }
+
int TSettings::PowerOf2Mask(int val) {
int mask = 1;
while ((val & mask) != val) {
diff --git a/library/cpp/actors/core/log_settings.h b/library/cpp/actors/core/log_settings.h
index 7fe4504edd..cf9a359db7 100644
--- a/library/cpp/actors/core/log_settings.h
+++ b/library/cpp/actors/core/log_settings.h
@@ -3,8 +3,8 @@
#include "actor.h"
#include "log_iface.h"
#include <util/generic/vector.h>
-#include <util/digest/murmur.h>
-#include <util/random/easy.h>
+#include <util/digest/murmur.h>
+#include <util/random/easy.h>
namespace NActors {
namespace NLog {
@@ -68,7 +68,7 @@ namespace NActors {
};
struct TSettings: public TThrRefBase {
- public:
+ public:
TActorId LoggerActorId;
EComponent LoggerComponent;
ui64 TimeThresholdMs;
@@ -80,20 +80,20 @@ namespace NActors {
EComponent MaxVal;
EComponent Mask;
EPriority DefPriority;
- EPriority DefSamplingPriority;
- ui32 DefSamplingRate;
+ EPriority DefSamplingPriority;
+ ui32 DefSamplingRate;
bool UseLocalTimestamps;
- enum ELogFormat {
- PLAIN_FULL_FORMAT,
- PLAIN_SHORT_FORMAT,
- JSON_FORMAT
- };
- ELogFormat Format;
+ enum ELogFormat {
+ PLAIN_FULL_FORMAT,
+ PLAIN_SHORT_FORMAT,
+ JSON_FORMAT
+ };
+ ELogFormat Format;
TString ShortHostName;
TString ClusterName;
TString MessagePrefix;
-
+
// The best way to provide minVal, maxVal and func is to have
// protobuf enumeration of components. In this case protoc
// automatically generates YOURTYPE_MIN, YOURTYPE_MAX and
@@ -106,7 +106,7 @@ namespace NActors {
TSettings(const TActorId& loggerActorId, const EComponent loggerComponent,
EPriority defPriority, EPriority defSamplingPriority = PRI_DEBUG,
ui32 defSamplingRate = 0, ui64 timeThresholdMs = 1000);
-
+
void Append(EComponent minVal, EComponent maxVal, EComponentToStringFunc func);
template <typename T>
@@ -145,10 +145,10 @@ namespace NActors {
inline TComponentSettings GetComponentSettings(EComponent component) const {
Y_VERIFY_DEBUG((component & Mask) == component);
- // by using Mask we don't get outside of array boundaries
+ // by using Mask we don't get outside of array boundaries
return TComponentSettings(AtomicGet(ComponentInfo[component & Mask]));
- }
-
+ }
+
const char* ComponentName(EComponent component) const {
Y_VERIFY_DEBUG((component & Mask) == component);
return ComponentNames[component & Mask].data();
@@ -164,9 +164,9 @@ namespace NActors {
void SetAllowDrop(bool val);
void SetThrottleDelay(TDuration value);
void SetUseLocalTimestamps(bool value);
-
- private:
- int SetLevelImpl(
+
+ private:
+ int SetLevelImpl(
const TString& name, bool isSampling,
EPriority priority, EComponent component, TString& explanation);
};