Class: Navy::ScopedLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/navy/scoped_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, scope = nil) ⇒ ScopedLogger

Returns a new instance of ScopedLogger.



5
6
7
# File 'lib/navy/scoped_logger.rb', line 5

def initialize(logger, scope = nil)
  @logger, @scope = logger, scope
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)



39
40
41
# File 'lib/navy/scoped_logger.rb', line 39

def method_missing(name, *args, &block)
  @logger.__send__(name, *args, &block)
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/navy/scoped_logger.rb', line 3

def logger
  @logger
end

#scopeObject

Returns the value of attribute scope.



3
4
5
# File 'lib/navy/scoped_logger.rb', line 3

def scope
  @scope
end

Instance Method Details

#add(*args, &block) ⇒ Object



9
10
11
# File 'lib/navy/scoped_logger.rb', line 9

def add(*args, &block)
  scoped(:add, *args, &block)
end

#debug(*args, &block) ⇒ Object



13
14
15
# File 'lib/navy/scoped_logger.rb', line 13

def debug(*args, &block)
  scoped(:debug, *args, &block)
end

#error(*args, &block) ⇒ Object



25
26
27
# File 'lib/navy/scoped_logger.rb', line 25

def error(*args, &block)
  scoped(:error, *args, &block)
end

#fatal(*args, &block) ⇒ Object



29
30
31
# File 'lib/navy/scoped_logger.rb', line 29

def fatal(*args, &block)
  scoped(:fatal, *args, &block)
end

#info(*args, &block) ⇒ Object



17
18
19
# File 'lib/navy/scoped_logger.rb', line 17

def info(*args, &block)
  scoped(:info, *args, &block)
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/navy/scoped_logger.rb', line 33

def respond_to?(*args)
  @logger.respond_to?(*args)
end

#warn(*args, &block) ⇒ Object



21
22
23
# File 'lib/navy/scoped_logger.rb', line 21

def warn(*args, &block)
  scoped(:warn, *args, &block)
end