Sha256: cf78b8b30301e58322d8d57f4d4d9fbbf6979fd7471b6a139750ba18b78da783
Contents?: true
Size: 818 Bytes
Versions: 2
Compression:
Stored size: 818 Bytes
Contents
require 'log_switch' 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(_, time, _, msg) "[#{time.strftime('%Y-%m-%d %H:%M:%S')}] #{msg}\n" 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(_) define_method :log do |*args| class_minus_main_name = self.class.to_s.sub(/^.*::/, '') args.first.insert(0, "<#{class_minus_main_name}> ") Tailor::Logger.log(*args) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tailor-1.4.1 | lib/tailor/logger.rb |
tailor-1.4.0 | lib/tailor/logger.rb |