module Fluent # 1. patch to avoid writing the configuration dump # until suppress config dump option will be supported. # https://github.com/fluent/fluentd/pull/186 # 2. patch to support custom depth_offset class Log # This is used for checking if patched # flydata-core/logger.rb uses this attr_accessor :flydata_patched def trace(*args, &block) return if @level > LEVEL_TRACE args << block.call if block depth_offset = extract_depth_offset(args) time, msg = event(:trace, args) puts [@color_trace, caller_line(time, depth_offset, LEVEL_TRACE), msg, @color_reset].join rescue # logger should not raise an exception. This rescue prevents unexpected behaviour. end def debug(*args, &block) return if @level > LEVEL_DEBUG args << block.call if block depth_offset = extract_depth_offset(args) time, msg = event(:debug, args) puts [@color_debug, caller_line(time, depth_offset, LEVEL_DEBUG), msg, @color_reset].join rescue end def warn(*args, &block) return if @level > LEVEL_WARN args << block.call if block depth_offset = extract_depth_offset(args) time, msg = event(:warn, args) if msg and m = /^parameter '(?[^']+)' in/.match(msg.strip) msg = "parameter '#{m[:param]}' is not used." end puts [@color_warn, caller_line(time, depth_offset, LEVEL_WARN), msg, @color_reset].join rescue end def info(*args, &block) return if @level > LEVEL_INFO args << block.call if block depth_offset = extract_depth_offset(args) time, msg = event(:info, args) puts [@color_info, caller_line(time, depth_offset, LEVEL_INFO), msg, @color_reset].join rescue end def error(*args, &block) return if @level > LEVEL_ERROR args << block.call if block depth_offset = extract_depth_offset(args) time, msg = event(:error, args) puts [@color_error, caller_line(time, depth_offset, LEVEL_ERROR), msg, @color_reset].join rescue end private def extract_depth_offset(args) opt = args.last if opt.kind_of?(Hash) and opt[:depth_offset].kind_of?(Integer) return opt.delete(:depth_offset) end @depth_offset end end end