Skip to content

Commit

Permalink
Use setter method for m_TimeFormat, set time format in Daemon.cpp ins…
Browse files Browse the repository at this point in the history
…tead of Log.cpp
  • Loading branch information
l-n-s committed Sep 19, 2017
1 parent d500fe6 commit 681810e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions daemon/Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
3 changes: 0 additions & 3 deletions libi2pd/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

#include "Log.h"
#include "Config.h"

namespace i2p {
namespace log {
Expand Down Expand Up @@ -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));
}
}
Expand Down
6 changes: 6 additions & 0 deletions libi2pd/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ namespace log {
*/
void SendTo (std::shared_ptr<std::ostream> 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
Expand Down

0 comments on commit 681810e

Please sign in to comment.