diff --git a/daemon/Daemon.cpp b/daemon/Daemon.cpp index 32595390..658bf011 100644 --- a/daemon/Daemon.cpp +++ b/daemon/Daemon.cpp @@ -94,8 +94,12 @@ namespace i2p std::string logs = ""; i2p::config::GetOption("log", logs); std::string logfile = ""; i2p::config::GetOption("logfile", logfile); std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel); + bool logclftime; i2p::config::GetOption("logclftime", logclftime); /* setup logging */ + if (logclftime) + i2p::log::Logger().SetTimeFormat ("[%d/%b/%Y:%H:%M:%S %z]"); + if (isDaemon && (logs == "" || logs == "stdout")) logs = "file"; diff --git a/libi2pd/Log.cpp b/libi2pd/Log.cpp index 0430ed57..8ae417c2 100644 --- a/libi2pd/Log.cpp +++ b/libi2pd/Log.cpp @@ -7,7 +7,6 @@ */ #include "Log.h" -#include "Config.h" namespace i2p { namespace log { @@ -74,8 +73,6 @@ namespace log { if (!m_IsRunning) { m_IsRunning = true; - bool logclftime; i2p::config::GetOption("logclftime", logclftime); - if (logclftime) m_TimeFormat = "[%d/%b/%Y:%H:%M:%S %z]"; m_Thread = new std::thread (std::bind (&Log::Run, this)); } } diff --git a/libi2pd/Log.h b/libi2pd/Log.h index e3ce65cd..bec741a8 100644 --- a/libi2pd/Log.h +++ b/libi2pd/Log.h @@ -108,6 +108,12 @@ namespace log { */ void SendTo (std::shared_ptr os); + /** + * @brief Sets format for timestamps in log + * @param format String with timestamp format + */ + void SetTimeFormat (std::string format) { m_TimeFormat = format; }; + #ifndef _WIN32 /** * @brief Sets log destination to syslog