- config-file: command line to specify a file where the hosts and other
configuration information are provided.
- daemon: run the application as a daemon.
+- log-level: apply a filter of which log messages will be printed. The available
+ options are the default Unix levels (e.g. debug, info, etc.).
#include "config/configurationreader.h"
#include "config/host.h"
#include "link/linkstatus.h"
+#include "host/loglevel.h"
#include "host/pingerfactory.h"
#include "host/pingprotocol.h"
#include "host/pingscheduler.h"
// Declarations
//-----------------------------------------------------------------------------
-// TODO: Change back to Notice log level
-const int default_log_level = I2n::Logger::LogLevel::Info;
-
ConfigurationItem get_configuration(int, const char**);
LinkStatusItem get_status_notifier(const ConfigurationItem&);
void init_logger();
void start_pingers(const PingSchedulerList&);
void stop_pingers(const PingSchedulerList&);
void block_all_signals();
-void handle_signals();
+void handle_signals(const int default_log_level);
//-----------------------------------------------------------------------------
// Definitions
void init_logger()
{
+ const int default_log_level = I2n::Logger::LogLevel::Info;
+
I2n::Logger::enable_syslog( I2n::Logger::Facility::User ); //lint !e1786
I2n::Logger::set_log_level( default_log_level ); //lint !e534
}
/**
* @brief Wait until a signal receives and act upon it
*
+ * @param default_log_level
+ *
* @return void
**/
-void handle_signals()
+void handle_signals( const int default_log_level )
{
// Wait for signals
sigset_t all_signals;
ConfigurationItem configuration = get_configuration( argc, argv );
if ( configuration.get() != NULL )
{
+ int log_level = configuration->get_log_level();
+ I2n::Logger::set_log_level( log_level );
bool daemon_mode = configuration->get_daemon();
if ( daemon_mode )
start_pingers( scheduler_list );
// React to signals (main thread will sleep)
- handle_signals();
+ handle_signals( log_level );
stop_pingers( scheduler_list );