From d30ad049c837c1334374e4828cbdb87bae147bd7 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 22 Sep 2015 18:35:19 +0200 Subject: [PATCH] Added disable_logfile token to Windows Agent --- pandora_agents/win32/bin/pandora_agent.conf | 6 ++-- pandora_agents/win32/pandora.cc | 28 +++++++++++++++---- pandora_agents/win32/pandora.h | 1 + .../win32/pandora_windows_service.cc | 5 +++- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 7693fba42f..3ec979f1d0 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -65,6 +65,9 @@ server_port 41121 # In case of using FTP or tentacle with password. User is always "pandora" #server_pwd pandora +# If set to 1 disables log writing into pandora_agent.log +#disable_logfile 1 + # Debug mode do not copy XML data files to server. # debug 1 @@ -75,9 +78,6 @@ remote_config 0 # XML encoding (ISO-8859-1 by default). Most windows servers experience problems when you set to UTF-8. Other special codepages may be specified here. #encoding ISO-8859-1 -# Config file encoding. Some windows text editors has ANSI default and others UTF-8 -#config_file_encoding UTF-8 - # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 181d3081df..5ce8ed2933 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -35,6 +35,7 @@ using namespace Pandora_Strutils; string pandora_path; string pandora_dir; bool pandora_debug; +bool pandora_log_disable; string pandora_version = PANDORA_VERSION; /** @@ -143,14 +144,17 @@ pandoraWriteLog (string filename, string line) { */ void Pandora::pandoraLog (const char *format, ...) { - va_list args; - char msg[5000]; + if (!pandora_log_disable) { + va_list args; + char msg[5000]; - va_start (args, format); - vsprintf (msg, format, args); - va_end (args); + va_start (args, format); + vsprintf (msg, format, args); + va_end (args); - pandoraWriteLog ("pandora_agent.log", (char *) msg); + pandoraWriteLog ("pandora_agent.log", (char *) msg); + } + return; } /** @@ -275,6 +279,18 @@ Pandora::getPandoraDebug () { return pandora_debug; } +/** + * Set the disable logfile flag. + * + * If the flag is true no logs will be written. + * + * @param dbg Turns the debug flag on/off. + * + */ +void +Pandora::setPandoraLogDisable (bool dbg) { + pandora_log_disable = dbg; +} /** * Get the version of the agent. diff --git a/pandora_agents/win32/pandora.h b/pandora_agents/win32/pandora.h index 8fb1cd268f..0469ab61dd 100644 --- a/pandora_agents/win32/pandora.h +++ b/pandora_agents/win32/pandora.h @@ -76,6 +76,7 @@ namespace Pandora { string getPandoraInstallPath (); void setPandoraDebug (bool dbg); bool getPandoraDebug (); + void setPandoraLogDisable (bool dbg); string getPandoraAgentVersion (); void pandoraDebug (const char *format, ...); diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index fe5980e8d4..0fe2e97848 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -205,7 +205,7 @@ Pandora_Windows_Service::check_broker_agents(string *all_conf){ void Pandora_Windows_Service::pandora_init () { - string conf_file, interval, debug, intensive_interval, util_dir, path, env; + string conf_file, interval, debug, disable_logfile, intensive_interval, util_dir, path, env; string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr; string name_agent, name; string proxy_mode, server_ip; @@ -264,6 +264,9 @@ Pandora_Windows_Service::pandora_init () { debug = conf->getValue ("debug"); setPandoraDebug (is_enabled (debug)); + + disable_logfile = conf->getValue ("disable_logfile"); + setPandoraLogDisable (is_enabled(disable_logfile)); if (first_run == 1) { first_run = 0;