Browse Source

* Daemon.cpp : move logs init to single place

pull/358/head
hagen 9 years ago
parent
commit
4bb4012d87
  1. 30
      Daemon.cpp

30
Daemon.cpp

@ -67,11 +67,6 @@ namespace i2p
std::string tunconf = i2p::util::filesystem::GetTunnelsConfigFile().string(); std::string tunconf = i2p::util::filesystem::GetTunnelsConfigFile().string();
std::string datadir = i2p::util::filesystem::GetDataDir().string(); std::string datadir = i2p::util::filesystem::GetDataDir().string();
LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
LogPrint(eLogDebug, "FS: main config file: ", config);
LogPrint(eLogDebug, "FS: tunnels config: ", tunconf);
LogPrint(eLogDebug, "FS: data directory: ", datadir);
i2p::config::ParseConfig(config); i2p::config::ParseConfig(config);
i2p::config::Finalize(); i2p::config::Finalize();
@ -80,10 +75,12 @@ namespace i2p
i2p::config::GetOption("daemon", isDaemon); i2p::config::GetOption("daemon", isDaemon);
// temporary hack // TODO: move log init here
std::string logs = "";
i2p::config::GetOption("log", logs); LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
if (isDaemon || logs != "") isLogging = true; LogPrint(eLogDebug, "FS: main config file: ", config);
LogPrint(eLogDebug, "FS: tunnels config: ", tunconf);
LogPrint(eLogDebug, "FS: data directory: ", datadir);
uint16_t port; i2p::config::GetOption("port", port); uint16_t port; i2p::config::GetOption("port", port);
if (port) if (port)
@ -135,16 +132,18 @@ namespace i2p
bool Daemon_Singleton::start() bool Daemon_Singleton::start()
{ {
std::string logs = ""; i2p::config::GetOption("log", logs);
std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel); std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
// temporary hack
if (isDaemon || logs != "") isLogging = true;
if (isLogging) if (isLogging)
{ {
// set default to stdout
std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
if (logfile == "") if (logfile == "")
{ {
// can't log to stdout, use autodetect of logfile // use autodetect of logfile
logfile = IsService () ? "/var/log" : i2p::util::filesystem::GetDataDir().string(); logfile = IsService () ? "/var/log" : i2p::util::filesystem::GetDataDir().string();
#ifndef _WIN32 #ifndef _WIN32
logfile.append("/i2pd.log"); logfile.append("/i2pd.log");
@ -153,9 +152,10 @@ namespace i2p
#endif #endif
} }
StartLog (logfile); StartLog (logfile);
} } else {
else // use stdout
StartLog (""); StartLog ("");
}
SetLogLevel(loglevel); SetLogLevel(loglevel);
bool http; i2p::config::GetOption("http.enabled", http); bool http; i2p::config::GetOption("http.enabled", http);

Loading…
Cancel
Save