Skip to content

Commit

Permalink
Change sai log level before discovery to prevent SAI ERR spam to the …
Browse files Browse the repository at this point in the history
…log (sonic-net#316)
  • Loading branch information
pavel-shirshov authored May 14, 2018
1 parent 177f768 commit 39a5d14
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3054,6 +3054,21 @@ void set_sai_api_loglevel()
}
}

void set_sai_api_log_min_prio(const std::string &prioStr)
{
SWSS_LOG_ENTER();

/*
* We start from 1 since 0 is SAI_API_UNSPECIFIED.
*/

for (uint32_t idx = 1; idx < sai_metadata_enum_sai_api_t.valuescount; ++idx)
{
const auto& api_name = sai_metadata_enum_sai_api_t.valuesnames[idx];
saiLoglevelNotify(api_name, prioStr);
}
}

void performWarmRestart()
{
SWSS_LOG_ENTER();
Expand Down
3 changes: 3 additions & 0 deletions syncd/syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,7 @@ sai_status_t processBulkEvent(
_In_ sai_common_api_t api,
_In_ const swss::KeyOpFieldsValuesTuple &kco);

void set_sai_api_log_min_prio(
_In_ const std::string &prio);

#endif // __SYNCD_H__
3 changes: 2 additions & 1 deletion syncd/syncd_saiswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,9 @@ void SaiSwitch::helperDiscover()

{
SWSS_LOG_TIMER("discover");

set_sai_api_log_min_prio("SAI_LOG_LEVEL_CRITICAL");
saiDiscover(m_switch_rid, m_discovered_rids);
set_sai_api_log_min_prio("SAI_LOG_LEVEL_NOTICE");
}

SWSS_LOG_NOTICE("discovered objects count: %zu", m_discovered_rids.size());
Expand Down

0 comments on commit 39a5d14

Please sign in to comment.