Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Log version and level at startup #599

Merged
merged 1 commit into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions exe/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <pxp-agent/util/daemonize.hpp>

#include "version-inl.hpp"

#include <cpp-pcp-client/util/thread.hpp>
#include <cpp-pcp-client/util/chrono.hpp>

Expand Down Expand Up @@ -182,8 +184,8 @@ int main(int argc, char *argv[]) {
// Set up logging

try {
Configuration::Instance().setupLogging();
LOG_DEBUG("pxp-agent logging has been initialized");
auto loglevel = Configuration::Instance().setupLogging();
LOG_INFO("pxp-agent {1} started at {2} level", PXP_AGENT_VERSION, loglevel);
} catch (const Configuration::Error& e) {
boost::nowide::cout << lth_loc::format("Failed to configure logging: {1}\n"
"Cannot start pxp-agent", e.what());
Expand Down
3 changes: 2 additions & 1 deletion lib/inc/pxp-agent/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ class Configuration
/// Throw a Configuration::Error: in case of invalid the specified
/// log file is in a non-esixtent directory.
/// Other execeptions are propagated.
void setupLogging();
/// Returns the log level.
std::string setupLogging();

/// Ensure all required values are valid. If necessary, expand
/// file paths to the expected format.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static void validateLogDirPath(const std::string& logfile)
}
}

void Configuration::setupLogging()
std::string Configuration::setupLogging()
{
logfile_ = HW::GetFlag<std::string>("logfile");
pcp_access_logfile_ = HW::GetFlag<std::string>("pcp-access-logfile");
Expand Down Expand Up @@ -268,14 +268,14 @@ void Configuration::setupLogging()
loglevel,
pcp_access_fstream_ptr_);

LOG_DEBUG("Logging configured");

if (!log_on_stdout) {
// Configure platform-specific things for file logging
// NB: we do that after setting up lth_log in order to log in
// case of failure
configure_platform_file_logging();
}

return loglevel;
}

void Configuration::validate()
Expand Down
11 changes: 3 additions & 8 deletions locales/pxp-agent.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: pxp-agent 1.5.3\n"
"Project-Id-Version: pxp-agent 1.6.0\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
Expand Down Expand Up @@ -69,9 +69,9 @@ msgid ""
"Cannot start pxp-agent"
msgstr ""

#. debug
#. info
#: exe/main.cc
msgid "pxp-agent logging has been initialized"
msgid "pxp-agent {1} started at {2} level"
msgstr ""

#: exe/main.cc
Expand Down Expand Up @@ -172,11 +172,6 @@ msgstr ""
msgid "invalid log level: '{1}'"
msgstr ""

#. debug
#: lib/src/configuration.cc
msgid "Logging configured"
msgstr ""

#. info
#: lib/src/configuration.cc
msgid "Reopening the pxp-agent log file"
Expand Down