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

Custom logging to filter logs #58

Merged
merged 8 commits into from
Aug 23, 2013
Merged

Custom logging to filter logs #58

merged 8 commits into from
Aug 23, 2013

Conversation

petems
Copy link
Owner

@petems petems commented Aug 12, 2013

Fixes #42

Means we can just say to people "Run DEBUG=true FILTER=true" and they can copy paste directly with the filtered results for debugging and such 👍

Also, now a custom logging faraday middleware that adds some goodies like times and body of requests, which we can tweak for future features if needed 😸

@pearkes
Copy link
Collaborator

pearkes commented Aug 13, 2013

Oh, man, beautiful! This looks really good compared to the old debug output.

So much so that we should probably just make it the default for DEBUG. Maybe just have something like:

DEBUG=1 # prints normal, filtered output
DEBUG=2 # prints raw output

What do you think? Just to avoid having multiple environment variables.

@blom
Copy link
Collaborator

blom commented Aug 13, 2013

Looks very nice! I like making the filtered output the default as well, and therefore reducing this to one variable.

def filter_url(output)
if ENV['FILTER']
output = output.to_s.gsub!(/client_id=[a-zA-z0-9]*/,'client_id=[REDACTED]')
output = output.to_s.gsub!(/api_key=[a-zA-z0-9]*/,'api_key=[REDACTED]')
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably meant A-Z and not A-z here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good catch, will fix.

@pearkes
Copy link
Collaborator

pearkes commented Aug 13, 2013

Ah, one more thing. We should probably scrub out the set-cookie: _digitalocean2_session_v2=[SESSION_COOKIE], that's probably as good as a password.

@petems
Copy link
Owner Author

petems commented Aug 13, 2013

Good idea on the DEBUG=1 and 2, changed that now. Also, added the session token to be filtered as well 👍

Change redacted to a slightly nicer message
private

def filter(output)
if ENV['DEBUG'] == '2'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we just need to flip this around so it doesn't filter if it's == 2, and else, it does. Just so it's default if someone did a DEBUG=true or whatever. 👍

Copy link
Owner Author

Choose a reason for hiding this comment

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

Cool, done 👍

@petems
Copy link
Owner Author

petems commented Aug 23, 2013

Probably gonna merge this over the weekend if there's no objections? 👍

@pearkes
Copy link
Collaborator

pearkes commented Aug 23, 2013

Let's do it now! 👍

pearkes added a commit that referenced this pull request Aug 23, 2013
Custom logging to filter logs
@pearkes pearkes merged commit d94ebf8 into master Aug 23, 2013
@pearkes pearkes deleted the pm_filter_logs branch August 23, 2013 19:57
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.

Scrub API Keys from Logs
3 participants