mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-10 06:41:42 +02:00
--debug=<file.log> will log into <file.log>
This commit is contained in:
parent
aae0a7ee65
commit
ab8fe2e323
3 changed files with 27 additions and 15 deletions
|
@ -81,7 +81,7 @@ int main (int argc, char **argv)
|
|||
|
||||
OptionParser op("Allowed options");
|
||||
auto helpSwitch = op.add<Switch>("", "help", "produce help message");
|
||||
auto debugSwitch = op.add<Switch, Visibility::hidden>("", "debug", "enable debug logging");
|
||||
auto debugOption = op.add<Implicit<string>, Visibility::hidden>("", "debug", "enable debug logging", "");
|
||||
auto versionSwitch = op.add<Switch>("v", "version", "show version number");
|
||||
#if defined(HAS_ALSA)
|
||||
auto listSwitch = op.add<Switch>("l", "list", "list pcm devices");
|
||||
|
@ -142,12 +142,18 @@ int main (int argc, char **argv)
|
|||
if (instance <= 0)
|
||||
std::invalid_argument("instance id must be >= 1");
|
||||
|
||||
AixLog::Log::init(
|
||||
AixLog::Log::init<AixLog::SinkNative>("snapclient", AixLog::Severity::trace, AixLog::Type::special);
|
||||
if (debugOption->is_set())
|
||||
{
|
||||
make_shared<AixLog::SinkCout>(debugSwitch->is_set()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch->is_set()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#function)":"%Y-%m-%d %H-%M-%S [#severity]"),
|
||||
make_shared<AixLog::SinkNative>("snapclient", AixLog::Severity::trace, AixLog::Type::special)
|
||||
AixLog::Log::instance().add_logsink<AixLog::SinkCout>(AixLog::Severity::trace, AixLog::Type::all, "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)");
|
||||
if (!debugOption->value().empty())
|
||||
AixLog::Log::instance().add_logsink<AixLog::SinkFile>(AixLog::Severity::trace, AixLog::Type::all, debugOption->value(), "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)");
|
||||
}
|
||||
);
|
||||
else
|
||||
{
|
||||
AixLog::Log::instance().add_logsink<AixLog::SinkCout>(AixLog::Severity::info, AixLog::Type::all, "%Y-%m-%d %H-%M-%S [#severity]");
|
||||
}
|
||||
|
||||
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
|
|
2
externals/aixlog
vendored
2
externals/aixlog
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 9ecd25432f66f8a8cf291a9a5bae4fd137300af7
|
||||
Subproject commit 80ddcd98d5790adf7689f0862038aa99764737d4
|
|
@ -60,7 +60,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
OptionParser op("Allowed options");
|
||||
auto helpSwitch = op.add<Switch>("h", "help", "Produce help message");
|
||||
auto debugSwitch = op.add<Switch, Visibility::hidden>("", "debug", "enable debug logging");
|
||||
auto debugOption = op.add<Implicit<string>, Visibility::hidden>("", "debug", "enable debug logging", "");
|
||||
auto versionSwitch = op.add<Switch>("v", "version", "Show version number");
|
||||
/*auto portValue =*/ op.add<Value<size_t>>("p", "port", "Server port", settings.port, &settings.port);
|
||||
/*auto controlPortValue =*/ op.add<Value<size_t>>("", "controlPort", "Remote control port", settings.controlPort, &settings.controlPort);
|
||||
|
@ -127,12 +127,18 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
AixLog::Log::init(
|
||||
AixLog::Log::init<AixLog::SinkNative>("snapserver", AixLog::Severity::trace, AixLog::Type::special);
|
||||
if (debugOption->is_set())
|
||||
{
|
||||
make_shared<AixLog::SinkCout>(debugSwitch->is_set()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch->is_set()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag)":"%Y-%m-%d %H-%M-%S [#severity]"),
|
||||
make_shared<AixLog::SinkNative>("snapserver", AixLog::Severity::trace, AixLog::Type::special)
|
||||
AixLog::Log::instance().add_logsink<AixLog::SinkCout>(AixLog::Severity::trace, AixLog::Type::all, "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)");
|
||||
if (!debugOption->value().empty())
|
||||
AixLog::Log::instance().add_logsink<AixLog::SinkFile>(AixLog::Severity::trace, AixLog::Type::all, debugOption->value(), "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)");
|
||||
}
|
||||
);
|
||||
else
|
||||
{
|
||||
AixLog::Log::instance().add_logsink<AixLog::SinkCout>(AixLog::Severity::info, AixLog::Type::all, "%Y-%m-%d %H-%M-%S [#severity]");
|
||||
}
|
||||
|
||||
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue