Skip to content

Commit

Permalink
A new flag is introduced by the agent to permit syslogging
Browse files Browse the repository at this point in the history
 of sessions that only obey SLO. Syslog is enabled if
either of use_syslog or use_session_syslog is enabled.
use_syslog to send sampled sessions to syslog;
use_session_syslog to send SLO sessions to syslog.
If use_syslog is enabled we dont send the session to
collector.
If only use_session_syslog is enabled, we send SLO
sessions to syslog but sampled sessions will continue
to go to collector.
Partial-Bug: 1729812

Change-Id: I02d6f3c3f369eb62343ee2f3237e3afdf2b4f002
  • Loading branch information
arvindvis committed Feb 11, 2018
1 parent 811b16e commit a55c19b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 6 additions & 2 deletions sandesh/compiler/generate/t_cpp_generator.cc
Expand Up @@ -1590,7 +1590,7 @@ void t_cpp_generator::generate_sandesh_flow_send_fn(ofstream &out,
out << indent() << "return;" << endl;
scope_down(out);
out << indent() <<
"if (IsFlowLoggingEnabled() && LoggingUseSyslog()) {" << endl;
"if (IsFlowLoggingEnabled() && LoggingUseSyslog()) { " << endl;
indent_up();
out << indent() << "UpdateTxMsgFailStats(\"" << tsandesh->get_name() <<
"\", 0, SandeshTxDropReason::SendingToSyslog);" << endl;
Expand All @@ -1599,12 +1599,16 @@ void t_cpp_generator::generate_sandesh_flow_send_fn(ofstream &out,
out << indent() << "LogUnrolled" <<
generate_sandesh_async_creator(tsandesh, false,
false, false, "", "", false, false, false) << ";" << endl;
out << indent() << "if (!IsSloSyslogEnabled()) {" << endl;
indent_up();
out << indent() << "return;" << endl;
scope_down(out);
} else {
out << indent() << "Log" <<
generate_sandesh_async_creator(tsandesh, false,
false, false, "", "", false, false, false) << ";" << endl;
out << indent() << "return;" << endl;
}
out << indent() << "return;" << endl;
scope_down(out);
out << indent() << "if (IsSendingAllMessagesDisabled() ||" <<
" IsSendingFlowsDisabled()) {" << endl;
Expand Down
15 changes: 14 additions & 1 deletion sandesh/library/cpp/sandesh.cc
Expand Up @@ -45,6 +45,7 @@ using namespace contrail::sandesh::transport;
Sandesh::SandeshRole::type Sandesh::role_ = SandeshRole::Invalid;
bool Sandesh::enable_local_log_ = false;
bool Sandesh::enable_flow_log_ = false;
bool Sandesh::enable_session_syslog_ = false;
int Sandesh::http_port_ = 0;
bool Sandesh::enable_trace_print_ = false;
bool Sandesh::send_queue_enabled_ = true;
Expand Down Expand Up @@ -349,12 +350,14 @@ void Sandesh::Uninit() {
}

void Sandesh::SetLoggingParams(bool enable_local_log, std::string category,
std::string level, bool enable_trace_print, bool enable_flow_log) {
std::string level, bool enable_trace_print, bool enable_flow_log,
bool enable_session_syslog) {
SetLocalLogging(enable_local_log);
SetLoggingCategory(category);
SetLoggingLevel(level);
SetTracePrint(enable_trace_print);
SetFlowLogging(enable_flow_log);
SetSessionSyslogging(enable_session_syslog);
}

void Sandesh::SetLoggingParams(bool enable_local_log, std::string category,
Expand Down Expand Up @@ -451,6 +454,16 @@ void Sandesh::SetFlowLogging(bool enable_flow_log) {
}
}

void Sandesh::SetSessionSyslogging(bool enable_session_syslog) {
if (enable_session_syslog_ != enable_session_syslog) {
SANDESH_LOG(INFO, "SANDESH: Flow Logging: " <<
(enable_session_syslog_ ? "ENABLED" : "DISABLED") << " -> " <<
(enable_session_syslog ? "ENABLED" : "DISABLED"));
enable_session_syslog_ = enable_session_syslog;
}

}

void Sandesh::DisableFlowCollection(bool disable) {
if (disable_flow_collection_ != disable) {
SANDESH_LOG(INFO, "SANDESH: Disable Flow Collection: " <<
Expand Down
5 changes: 4 additions & 1 deletion sandesh/library/cpp/sandesh.h
Expand Up @@ -212,7 +212,7 @@ class Sandesh {
// Logging and category APIs
static void SetLoggingParams(bool enable_local_log, std::string category,
std::string level, bool enable_trace_print = false,
bool enable_flow_log = false);
bool enable_flow_log = false, bool enable_session_syslog = false);
static void SetLoggingParams(bool enable_local_log, std::string category,
SandeshLevel::type level, bool enable_trace_print = false,
bool enable_flow_log = false);
Expand All @@ -223,7 +223,9 @@ class Sandesh {
static bool IsLocalLoggingEnabled() { return enable_local_log_; }
static void SetLocalLogging(bool enable);
static bool IsFlowLoggingEnabled() { return enable_flow_log_; }
static bool IsSloSyslogEnabled() { return enable_session_syslog_; }
static void SetFlowLogging(bool enable);
static void SetSessionSyslogging(bool enable_session_syslog);
static bool IsTracePrintEnabled() { return enable_trace_print_; }
static void SetTracePrint(bool enable);
static void SetLoggingCategory(std::string category);
Expand Down Expand Up @@ -397,6 +399,7 @@ class Sandesh {
static ModuleContextMap module_context_;
static bool enable_local_log_; // whether to just enable local logging
static bool enable_flow_log_; // whether to enable flow sandesh message logging
static bool enable_session_syslog_; // whether to enable syslog for SLO session messages
static SandeshLevel::type logging_level_; // current logging level
static SandeshLevel::type logging_ut_level_; // ut_debug logging level
static std::string logging_category_; // current logging category
Expand Down

0 comments on commit a55c19b

Please sign in to comment.