Skip to content

Instantly share code, notes, and snippets.

@lotherk
Created March 11, 2014 20:02
Show Gist options
  • Save lotherk/9493843 to your computer and use it in GitHub Desktop.
Save lotherk/9493843 to your computer and use it in GitHub Desktop.
module TTVDB
def self.logger(output=STDOUT)
unless @logger
@logger = Logger.new(output)
@logger.formatter = proc { |severity, datetime, progname, msg|
kaller = caller[4]
file, ln, func = kaller.split(":")
_nil, func = func.split("`")
func.gsub!(/[<>']/, "")
file = File.basename(file)
"#{datetime} #{severity} #{file}:#{func}:#{ln}: #{msg}\n"
}
end
@logger
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment