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

Conversation

MikaelSmith
Copy link
Contributor

Logs pxp-agent version and configured log level as soon as logging is
configured. Clarifies when versions change in logging, which makes
debugging issues easier.

@puppetcla
Copy link

CLA signed by all contributors.

@MikaelSmith
Copy link
Contributor Author

MikaelSmith commented Jun 27, 2017

Default output now is

2017-06-27 08:17:10.491037 INFO  puppetlabs.pxp_agent.main:187 - pxp-agent 1.6.0 started at info level
2017-06-27 08:17:10.501301 INFO  puppetlabs.pxp_agent.main:203 - pxp-agent configuration has been validated
2017-06-27 08:17:10.501416 INFO  puppetlabs.pxp_agent.agent:29 - Connecting using PCP v2
2017-06-27 08:17:10.501614 INFO  puppetlabs.cpp_pcp_client.client_metadata:125 - Retrieved common name from the certificate and determined the client URI: pcp://client02.example.com/agent
2017-06-27 08:17:10.502046 INFO  puppetlabs.pxp_agent.request_processor:767 - Loading external modules configuration from /etc/puppetlabs/pxp-agent/modules
2017-06-27 08:17:10.502735 INFO  puppetlabs.pxp_agent.request_processor:818 - Loading external modules from /Users/michaelsmith/puppetlabs/pxp-agent/modules
2017-06-27 08:17:12.350269 INFO  puppetlabs.pxp_agent.results_storage:221 - About to purge the results directories from '/Users/michaelsmith/puppetlabs/pxp-agent/dev-resources/spool'; TTL = 14d
2017-06-27 08:17:12.352660 INFO  puppetlabs.pxp_agent.results_storage:270 - Removed 0 directories from '/Users/michaelsmith/puppetlabs/pxp-agent/dev-resources/spool'
2017-06-27 08:17:12.352899 INFO  puppetlabs.pxp_agent.request_processor:908 - Starting the task for purging the spool directory every 24192 minutes; thread id 0x7000092cb000
2017-06-27 08:17:12.357380 INFO  puppetlabs.cpp_pcp_client.connection:395 - Establishing the WebSocket connection with 'wss://broker.example.com:8142/pcp2/agent' with a timeout of 5000 ms

exe/main.cc Outdated
LOG_DEBUG("pxp-agent logging has been initialized");
std::string version, loglevel;
std::tie(version, loglevel) = Configuration::Instance().setupLogging();
LOG_INFO("pxp-agent {1} started at {2} level", version, loglevel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest returning only the log level from the Configuration::Instance().setupLogging() method and using the PXP_AGENT_VERSION here directly. The rationale being that the PXP_AGENT_VERSION define is relevant to all of the pxp-agent code not just logging, so it seems inappropriate to return its value from the logging setup function. Moreover by simplifying the setupLogging()'s return value we'll be able to avoid having to pack/unpack the two values to/from the std::pair.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

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 std::make_pair(PXP_AGENT_VERSION, loglevel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested above: Return just the log level from the method.

Logs pxp-agent version and configured log level as soon as logging is
configured. Clarifies when versions change in logging, which makes
debugging issues easier.
Copy link
Contributor

@mruzicka mruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mruzicka mruzicka merged commit 15a5af5 into puppetlabs:master Jun 29, 2017
@MikaelSmith MikaelSmith deleted the log-starting branch June 29, 2017 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants