mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-09 07:17:53 +00:00
* add --logfile option
This commit is contained in:
parent
0c56cd63bd
commit
d2d4fa29e4
@ -111,6 +111,7 @@ namespace config {
|
|||||||
("tunconf", value<std::string>()->default_value(""), "Path to config with tunnels list and options (default: try ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg)")
|
("tunconf", value<std::string>()->default_value(""), "Path to config with tunnels list and options (default: try ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg)")
|
||||||
("pidfile", value<std::string>()->default_value(""), "Write pidfile to given path")
|
("pidfile", value<std::string>()->default_value(""), "Write pidfile to given path")
|
||||||
("log", value<bool>()->zero_tokens(), "Write logs to file instead stdout")
|
("log", value<bool>()->zero_tokens(), "Write logs to file instead stdout")
|
||||||
|
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)")
|
||||||
("loglevel", value<std::string>()->default_value("info"), "Set the minimal level of log messages (debug, info, warn, error)")
|
("loglevel", value<std::string>()->default_value("info"), "Set the minimal level of log messages (debug, info, warn, error)")
|
||||||
("host", value<std::string>()->default_value(""), "External IP (deprecated)")
|
("host", value<std::string>()->default_value(""), "External IP (deprecated)")
|
||||||
("port,p", value<uint16_t>()->default_value(4567), "Port to listen for incoming connections")
|
("port,p", value<uint16_t>()->default_value(4567), "Port to listen for incoming connections")
|
||||||
|
27
Daemon.cpp
27
Daemon.cpp
@ -116,22 +116,25 @@ namespace i2p
|
|||||||
|
|
||||||
bool Daemon_Singleton::start()
|
bool Daemon_Singleton::start()
|
||||||
{
|
{
|
||||||
// initialize log
|
|
||||||
if (isLogging)
|
if (isLogging)
|
||||||
{
|
{
|
||||||
if (isDaemon)
|
// set default to stdout
|
||||||
{
|
std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
|
||||||
std::string logfile_path = IsService () ? "/var/log" : i2p::util::filesystem::GetDataDir().string();
|
std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
|
||||||
#ifndef _WIN32
|
if (isDaemon && logfile == "") {
|
||||||
logfile_path.append("/i2pd.log");
|
// can't log to stdout, use autodetect of logfile
|
||||||
#else
|
if (IsService ()) {
|
||||||
logfile_path.append("\\i2pd.log");
|
logfile = "/var/log";
|
||||||
#endif
|
|
||||||
StartLog (logfile_path);
|
|
||||||
} else {
|
} else {
|
||||||
StartLog (""); // write to stdout
|
logfile = i2p::util::filesystem::GetDataDir().string();
|
||||||
}
|
}
|
||||||
std::string loglevel; i2p::config::GetOption("loglevel", loglevel);
|
#ifndef _WIN32
|
||||||
|
logfile.append("/i2pd.log");
|
||||||
|
#else
|
||||||
|
logfile.append("\\i2pd.log");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
StartLog (logfile);
|
||||||
g_Log->SetLogLevel(loglevel);
|
g_Log->SetLogLevel(loglevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user