Module: Logsly::LoggerMethods
- Defined in:
- lib/logsly.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
delegate all calls to the @logger
83
84
85
|
# File 'lib/logsly.rb', line 83
def method_missing(method, *args, &block)
@logger.send(method, *args, &block)
end
|
Instance Method Details
#==(other_logger) ⇒ Object
90
91
92
93
94
|
# File 'lib/logsly.rb', line 90
def ==(other_logger)
other_logger.log_type == @log_type &&
other_logger.level == @level &&
other_logger.outputs == @outputs
end
|
#file_path ⇒ Object
75
76
77
78
79
|
# File 'lib/logsly.rb', line 75
def file_path
@file_path ||= if (appender = get_file_appender)
appender.name if appender.respond_to?(:name)
end
end
|
#initialize(log_type, opts_hash = nil) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/logsly.rb', line 55
def initialize(log_type, opts_hash=nil)
opts = NsOptions::Struct.new(opts_hash) do
option :level, String, :default => 'info'
option :outputs, Array, :default => []
end
@log_type, @level, @outputs = log_type.to_s, opts.level, opts.outputs
unique_name = "#{self.class.name}-#{@log_type}-#{self.object_id}"
@logger = Logging.logger[unique_name]
@logger.level = @level
@outputs.each do |output|
add_appender(Logsly.outputs(output).to_appender(self))
end
end
|
#inspect ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/logsly.rb', line 96
def inspect
reference = '0x0%x' % (self.object_id << 1)
"#<#{self.class}:#{reference} "\
"@log_type=#{@log_type.inspect} "\
"@level=#{@level.inspect} "\
"@outputs=#{@outputs.inspect}"
end
|
#mdc(key, value) ⇒ Object
71
72
73
|
# File 'lib/logsly.rb', line 71
def mdc(key, value)
Logging.mdc[key] = value
end
|
#respond_to?(method) ⇒ Boolean
86
87
88
|
# File 'lib/logsly.rb', line 86
def respond_to?(method)
super || @logger.respond_to?(method)
end
|