Class: Fluent::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb

Overview

  1. patch to avoid writing the configuration dump

until suppress config dump option will be supported.
https://github.com/fluent/fluentd/pull/186
  1. patch to support custom depth_offset

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#flydata_patchedObject

This is used for checking if patched flydata-core/logger.rb uses this


10
11
12
# File 'lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb', line 10

def flydata_patched
  @flydata_patched
end

Instance Method Details

#debug(*args, &block) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb', line 22

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

#error(*args, &block) ⇒ Object


52
53
54
55
56
57
58
59
# File 'lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb', line 52

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

#info(*args, &block) ⇒ Object


43
44
45
46
47
48
49
50
# File 'lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb', line 43

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

#trace(*args, &block) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb', line 12

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

#warn(*args, &block) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/flydata/fluent-plugins/flydata_plugin_ext/fluent_log_ext.rb', line 31

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 '(?<param>[^']+)' 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