Skip to content

Instantly share code, notes, and snippets.

@mattrayner
Created November 14, 2014 11:35
Show Gist options
  • Save mattrayner/9f2e1934f3bb0060aa97 to your computer and use it in GitHub Desktop.
Save mattrayner/9f2e1934f3bb0060aa97 to your computer and use it in GitHub Desktop.
# Custom SSO logger
require 'singleton'
class SSOLogger < Logger
include Singleton
def initialize
super(Rails.root.join('log/sso.log'))
self.formatter = formatter()
self
end
# Optional, but good for prefixing timestamps automatically
def formatter
Proc.new{|severity, time, progname, msg|
formatted_severity = sprintf("%-5s",severity.to_s)
formatted_time = time.strftime("%Y-%m-%d %H:%M:%S")
"#{msg.to_s.strip}\n"
}
end
class << self
delegate :error, :debug, :fatal, :info, :warn, :add, :log, :to => :instance
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment