lib/tailor/logger.rb in tailor-1.0.0.alpha2 vs lib/tailor/logger.rb in tailor-1.0.0
- old
+ new
@@ -2,10 +2,12 @@
class Tailor
class Logger
extend LogSwitch
+ # Overrides the LogSwitch Logger to custom format the time format in log
+ # messages.
def self.logger
return @logger if @logger
@logger ||= ::Logger.new $stdout
def @logger.format_message(level, time, progname, msg)
@@ -13,9 +15,11 @@
end
@logger
end
+ # Provides an .included hook to insert the name of the class for each log
+ # message in the class that includes the Mixin.
module Mixin
def self.included(base)
define_method :log do |*args|
class_minus_main_name = self.class.to_s.sub(/^.*::/, '')
args.first.insert(0, "<#{class_minus_main_name}> ")