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

Improve log_exception output from PuppetContext #103

Merged
merged 1 commit into from
Jun 25, 2018
Merged

Improve log_exception output from PuppetContext #103

merged 1 commit into from
Jun 25, 2018

Conversation

da-ar
Copy link

@da-ar da-ar commented Jun 21, 2018

No description provided.

@da-ar da-ar added the bug label Jun 21, 2018
@da-ar da-ar requested a review from DavidS June 21, 2018 13:24
Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

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

The code change itself is 👍
Please add a test checking that Puppet[:trace] is evaluated.
Please also improve the commit message showing previous and current output explaining why this is better than before.


context 'when Puppet[:trace] is enabled' do
before(:each) do
Puppet[:trace] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

This will poison the settings for everyone else (especially if you also want to test Puppet[:trace] = false. Have you tried

allow(Puppet).to recieve[:[].and_call_original
allow(Puppet).to recieve[:[].with(:trace).and_return(true)

?

Rather than going through Puppets exception logger, uses the BaseContext log_exception function.  This provides better stack trace information and a clearer indication of where the exception was raised:

Before:

Error: #<Puppet::ResourceApi::PuppetContext::LoggingProxy:0x00007fec9fd90268>: Failed after 0.000160 seconds

After:

Error: user_admin[bob]: Updating: Failed after 0.000152 seconds: Role based administrator type missing `role_profile` attribute
@DavidS DavidS changed the title Revert some changes from PDK-1004 Improve log_exception output from PuppetContext Jun 25, 2018
@DavidS DavidS merged commit b81a77d into puppetlabs:master Jun 25, 2018
@da-ar da-ar deleted the error_logging branch July 9, 2018 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants