mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
* add --logfile option
This commit is contained in:
parent
0c56cd63bd
commit
d2d4fa29e4
2 changed files with 14 additions and 10 deletions
23
Daemon.cpp
23
Daemon.cpp
|
@ -116,22 +116,25 @@ namespace i2p
|
|||
|
||||
bool Daemon_Singleton::start()
|
||||
{
|
||||
// initialize log
|
||||
if (isLogging)
|
||||
{
|
||||
if (isDaemon)
|
||||
{
|
||||
std::string logfile_path = IsService () ? "/var/log" : i2p::util::filesystem::GetDataDir().string();
|
||||
// set default to stdout
|
||||
std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
|
||||
std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
|
||||
if (isDaemon && logfile == "") {
|
||||
// can't log to stdout, use autodetect of logfile
|
||||
if (IsService ()) {
|
||||
logfile = "/var/log";
|
||||
} else {
|
||||
logfile = i2p::util::filesystem::GetDataDir().string();
|
||||
}
|
||||
#ifndef _WIN32
|
||||
logfile_path.append("/i2pd.log");
|
||||
logfile.append("/i2pd.log");
|
||||
#else
|
||||
logfile_path.append("\\i2pd.log");
|
||||
logfile.append("\\i2pd.log");
|
||||
#endif
|
||||
StartLog (logfile_path);
|
||||
} else {
|
||||
StartLog (""); // write to stdout
|
||||
}
|
||||
std::string loglevel; i2p::config::GetOption("loglevel", loglevel);
|
||||
StartLog (logfile);
|
||||
g_Log->SetLogLevel(loglevel);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue