90fcba79c6
* Do not log events that are not critical (deadly) to the NIC router if not configured to be verbose, * Print almost all log lines with a prefix of the domain name they are related to, * And, do not use Genode::error and Genode::warning as they make it hard to read the log with the domain name prefixes. Fixes #2840
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
/*
|
|
* \brief Report generation unit
|
|
* \author Martin Stein
|
|
* \date 2016-08-24
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2016-2017 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
*/
|
|
|
|
/* local includes */
|
|
#include <report.h>
|
|
#include <xml_node.h>
|
|
#include <domain.h>
|
|
|
|
using namespace Net;
|
|
using namespace Genode;
|
|
|
|
|
|
Net::Report::Report(bool const &verbose,
|
|
Xml_node const node,
|
|
Timer::Connection &timer,
|
|
Domain_tree &domains,
|
|
Reporter &reporter)
|
|
:
|
|
_verbose(verbose),
|
|
_config(node.attribute_value("config", true)),
|
|
_config_triggers(node.attribute_value("config_triggers", false)),
|
|
_bytes(node.attribute_value("bytes", true)),
|
|
_reporter(reporter),
|
|
_domains(domains),
|
|
_timeout(timer, *this, &Report::_handle_report_timeout,
|
|
read_sec_attr(node, "interval_sec", 5))
|
|
{
|
|
_reporter.enabled(true);
|
|
}
|
|
|
|
|
|
void Net::Report::_report()
|
|
{
|
|
try {
|
|
Reporter::Xml_generator xml(_reporter, [&] () {
|
|
_domains.for_each([&] (Domain &domain) {
|
|
domain.report(xml);
|
|
});
|
|
});
|
|
} catch (Xml_generator::Buffer_exceeded) {
|
|
if (_verbose) {
|
|
log("Failed to generate report"); }
|
|
}
|
|
}
|
|
|
|
|
|
void Net::Report::_handle_report_timeout(Duration)
|
|
{
|
|
_report();
|
|
}
|
|
|
|
|
|
void Net::Report::handle_config()
|
|
{
|
|
if (!_config_triggers) {
|
|
return; }
|
|
|
|
_report();
|
|
}
|