Last active
December 17, 2015 21:59
-
-
Save blairio/5679017 to your computer and use it in GitHub Desktop.
Logging with log level and Process id. $$ is the pid
Put simple_formatter in config/initializers Apparently for Unicorn on Heroku apps you are supposed to add put_in_application to application.rb within class Application < Rails::Application
This file contains hidden or 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
if Rails.env[/production|staging/] | |
config.logger = Logger.new(STDOUT) | |
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO') | |
end |
This file contains hidden or 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
class Logger::SimpleFormatter | |
# This method is invoked when a log event occurs | |
def call(severity, timestamp, progname, msg) | |
"[#{severity}] [#{$$}] #{String === msg ? msg : msg.inspect}\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment