Add -log-level flag to pipedald.
This commit is contained in:
@@ -111,6 +111,17 @@ static void EnableBacktrace()
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool TryGetLogLevel(const std::string&strLogLevel,LogLevel*result)
|
||||
{
|
||||
if (strLogLevel == "debug") {*result= LogLevel::Debug; return true;}
|
||||
if (strLogLevel == "info") {*result= LogLevel::Info; return true;}
|
||||
if (strLogLevel == "warning") {*result= LogLevel::Warning; return true;}
|
||||
if (strLogLevel == "error") { *result= LogLevel::Error; return true;}
|
||||
*result = LogLevel::Info;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@@ -127,12 +138,14 @@ int main(int argc, char *argv[])
|
||||
bool error = false;
|
||||
bool systemd = false;
|
||||
bool testExtraDevice = false;
|
||||
std::string logLevel;
|
||||
std::string portOption;
|
||||
|
||||
CommandLineParser parser;
|
||||
parser.AddOption("-h", &help);
|
||||
parser.AddOption("--help", &help);
|
||||
parser.AddOption("-systemd", &systemd);
|
||||
parser.AddOption("-log-level",&logLevel);
|
||||
parser.AddOption("-port", &portOption);
|
||||
parser.AddOption("-test-extra-device", &testExtraDevice); // advertise two different devices (for testing multi-device connect)
|
||||
|
||||
@@ -167,6 +180,7 @@ int main(int argc, char *argv[])
|
||||
<< "Options:\n"
|
||||
<< " -systemd: Log to systemd journals instead of to the console.\n"
|
||||
<< " -port: Port to listen on e.g. 80, or 0.0.0.0:80\n"
|
||||
<< " -log-level: (debug|info|warning|error)"
|
||||
<< "Example:\n"
|
||||
<< " pipedald /etc/pipedal/config /etc/pipedal/react -port 80 \n"
|
||||
"\n"
|
||||
@@ -208,6 +222,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Lv2Log::log_level(configuration.GetLogLevel());
|
||||
if (logLevel.length() != 0)
|
||||
{
|
||||
LogLevel lv2LogLevel;
|
||||
if (TryGetLogLevel(logLevel,&lv2LogLevel))
|
||||
{
|
||||
Lv2Log::log_level(lv2LogLevel);
|
||||
|
||||
} else {
|
||||
Lv2Log::error(SS("Invalid log level: " << logLevel));
|
||||
return EXIT_SUCCESS; // indicate to systemd that we don't want a restart.
|
||||
}
|
||||
}
|
||||
|
||||
if (portOption.length() != 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user