Add failsafe logger for zones
Tested:
...
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `0` is in failsafe mode.
With update at `fleeting0`: The sensor has bad readings.
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `1` is in failsafe mode.
With update at `fleeting1`: The sensor has bad readings.
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `1` leaves failsafe mode.
With update at `hotswap_in_Input_Power`: The sensor has recovered.
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `0` leaves failsafe mode.
With update at `hotswap_in_Input_Power`: The sensor has recovered.
...
Change-Id: I2c296addb7ad117c03c04a27de91204796cda036
Signed-off-by: James Zheng <alphetis@google.com>
diff --git a/main.cpp b/main.cpp
index 76c5d19..e91d109 100644
--- a/main.cpp
+++ b/main.cpp
@@ -19,6 +19,7 @@
#include "buildjson/buildjson.hpp"
#include "conf.hpp"
#include "dbus/dbusconfiguration.hpp"
+#include "failsafeloggers/builder.hpp"
#include "interfaces.hpp"
#include "pid/builder.hpp"
#include "pid/buildjson.hpp"
@@ -165,6 +166,11 @@
state::mgmr = buildSensors(sensorConfig, passiveBus, hostBus);
state::zones =
buildZones(zoneConfig, zoneDetailsConfig, state::mgmr, modeControlBus);
+ // Set `logMaxCountPerSecond` to 20 will limit the number of logs output per
+ // second in each zone. Using 20 here would limit the output rate to be no
+ // larger than 100 per sec for most platforms as the number of zones are
+ // usually <=3. This will effectively avoid resource exhaustion.
+ buildFailsafeLoggers(state::zones, /* logMaxCountPerSecond = */ 20);
if (0 == state::zones.size())
{