Module: Logsly::InstanceMethods
- Defined in:
- lib/logsly.rb
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#log_type ⇒ Object
readonly
Returns the value of attribute log_type.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
Instance Method Summary collapse
- #==(other_logger) ⇒ Object
- #file_path ⇒ Object
- #initialize(log_type, opts = nil) ⇒ Object
- #inspect ⇒ Object
- #mdc(key, value) ⇒ Object
-
#method_missing(method, *args, &block) ⇒ Object
delegate all calls to the @logger.
- #respond_to?(method) ⇒ Boolean
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
77 78 79 |
# File 'lib/logsly.rb', line 77 def method_missing(method, *args, &block) @logger.send(method, *args, &block) end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
47 48 49 |
# File 'lib/logsly.rb', line 47 def level @level end |
#log_type ⇒ Object (readonly)
Returns the value of attribute log_type.
47 48 49 |
# File 'lib/logsly.rb', line 47 def log_type @log_type end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
47 48 49 |
# File 'lib/logsly.rb', line 47 def logger @logger end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
47 48 49 |
# File 'lib/logsly.rb', line 47 def outputs @outputs end |
Instance Method Details
#==(other_logger) ⇒ Object
84 85 86 87 88 |
# File 'lib/logsly.rb', line 84 def ==(other_logger) other_logger.log_type == @log_type && other_logger.level == @level && other_logger.outputs == @outputs end |
#file_path ⇒ Object
69 70 71 72 73 |
# File 'lib/logsly.rb', line 69 def file_path @file_path ||= if (appender = get_file_appender) appender.name if appender.respond_to?(:name) end end |
#initialize(log_type, opts = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/logsly.rb', line 49 def initialize(log_type, opts = nil) opts ||= {} @log_type = log_type.to_s @level = (opts[:level] || opts['level'] || 'info').to_s @outputs = [*(opts[:outputs] || opts['outputs'] || [])] unique_name = "#{self.class.name}-#{@log_type}-#{self.object_id}" @logger = Logsly::Logging182.logger[unique_name] @logger.level = @level @outputs.each do |output| add_appender(Logsly.outputs(output).to_appender(self)) end end |
#inspect ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/logsly.rb', line 90 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
65 66 67 |
# File 'lib/logsly.rb', line 65 def mdc(key, value) Logsly::Logging182.mdc[key] = value end |
#respond_to?(method) ⇒ Boolean
80 81 82 |
# File 'lib/logsly.rb', line 80 def respond_to?(method) super || @logger.respond_to?(method) end |