Skip to content

Instantly share code, notes, and snippets.

@blairio
Last active December 17, 2015 21:59
Show Gist options
  • Save blairio/5679017 to your computer and use it in GitHub Desktop.
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
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
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