new(userspace): add exception management

Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
This commit is contained in:
Andrea Terzolo 2022-07-13 13:24:17 +02:00 committed by poiana
parent e73dbd4b42
commit 4136a27de1

View File

@ -20,6 +20,7 @@ limitations under the License.
#include "statsfilewriter.h" #include "statsfilewriter.h"
#include "banned.h" // This raises a compilation error when certain functions are used #include "banned.h" // This raises a compilation error when certain functions are used
#include "logger.h"
using namespace std; using namespace std;
@ -118,6 +119,8 @@ void StatsFileWriter::handle()
delta.n_preemptions = cstats.n_preemptions - m_last_stats.n_preemptions; delta.n_preemptions = cstats.n_preemptions - m_last_stats.n_preemptions;
} }
try
{
jmsg["sample"] = m_num_stats; jmsg["sample"] = m_num_stats;
if(m_extra != "") if(m_extra != "")
{ {
@ -132,6 +135,11 @@ void StatsFileWriter::handle()
jmsg["delta"]["preemptions"] = delta.n_preemptions; jmsg["delta"]["preemptions"] = delta.n_preemptions;
jmsg["delta"]["drop_pct"] = (delta.n_evts == 0 ? 0 : (100.0*delta.n_drops/delta.n_evts)); jmsg["delta"]["drop_pct"] = (delta.n_evts == 0 ? 0 : (100.0*delta.n_drops/delta.n_evts));
m_output << jmsg.dump() << endl; m_output << jmsg.dump() << endl;
}
catch(const exception &e)
{
falco_logger::log(LOG_ERR, "StatsFileWriter (handle): " + string(e.what()) + "\n");
}
m_last_stats = cstats; m_last_stats = cstats;
} }