-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
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:
What do you think? Just to avoid having multiple environment variables. |
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]') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will fix.
Ah, one more thing. We should probably scrub out the |
Now uses 1 for regular output, and 2 for filtered logs
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' |
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, done 👍
…nto pm_filter_logs Conflicts: lib/tugboat/middleware/custom_logger.rb
Probably gonna merge this over the weekend if there's no objections? 👍 |
Let's do it now! 👍 |
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 😸