Created
March 30, 2010 20:47
-
-
Save afair/349579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
class MyLogger < ActiveSupport::BufferedLogger | |
SEVERITY_NAME = %w( DEBUG INFO WARN ERROR FATAL UNKNOWN ) | |
def custom_line(severity, message) | |
# Customized Log Format! | |
message = [Time.now.strftime("%Y-%m-%d %H:%M:%S"), ENV['BL_JOB_ID']||$$, SEVERITY_NAME[severity], message].join("\t") | |
end | |
def add(severity, message = nil, progname = nil, &block) | |
return if @level > severity | |
message = (message || (block && block.call) || progname).to_s | |
# If a newline is necessary then create a new message ending with a newline. | |
# Ensures that the original message is not mutated. | |
message = "#{message}\n" unless message[-1] == ?\n | |
message = custom_line(severity, message) # <== CUSTOMIZED | |
buffer << message | |
auto_flush | |
message | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment