-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Merged in capistrano_colors
gem, and renamed to 'log_formatters'
#283
Merged in capistrano_colors
gem, and renamed to 'log_formatters'
#283
Conversation
I've just added a complete set of tests for this feature at |
Agreed, this should be the default output ! |
❤️ |
@ndbroadbent Could you add TTY detection? |
@@ -29,6 +70,46 @@ def close | |||
|
|||
def log(level, message, line_prefix=nil) | |||
if level <= self.level | |||
# Don't format output if logger is outputting to a file, |
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.
@carsomyr - This is close to tty detection. It will only format the logs if they are being printed to stdout. No formatting will occur if they are being saved to a file
@ndbroadbent Why not go the whole way and use |
Not sure what you mean about using |
|
@ndbroadbent I was wondering if it would be better to use TTY detection on |
Ah, sorry, understood. I have changed those to class-instance variables |
how does 1f49d671123d36d7a174b2a7e10af881c8f3fff9 look, RE: tty ? |
@ndbroadbent re: the TTY check, I don't think you have to check if it's a file anymore (files aren't TTYs, AFAIK). re: the class-level instance variables, looks good. Squash all the commits? I wanna try it locally first. |
Great point, I've changed it to just do |
@ndbroadbent Some final nitpicky observations:
|
…ince it does much more than just colors
Thanks for the feedback, you're definitely raising some valid points! |
Merged in `capistrano_colors` gem, and renamed to 'log_formatters'
@ndbroadbent It's merged! Your next mission, should you choose to accept it... Well, you know which PR I am referring to. |
I can't imagine why anyone would want to use capistrano without the
capistrano_colors
formatting. We've been adding it to all of our Gemfiles for years now, and I strongly feel that it should be a default feature.capistrano_colors
also does more than just colors. It can change the log style (underline, etc.), and can even prepend text or timestamps to the line. That's why I decided to call it 'log_formatters' instead.Anyone can disable the new log formatting by adding
disable_log_formatters
to theirdeploy.rb
. This will turn off the formatters and produce the same output as before. Log formatting will be automatically disabled if the output device is a file.I've prepared a Log Formatters wiki page to add to the wiki index.
If this gets merged, I will be available to fix any bugs or issues.