Class: Protobuf::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/protobuf/common/logger.rb

Defined Under Namespace

Modules: LogMethods

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/protobuf/common/logger.rb', line 7

def file
  @file
end

.levelObject

Returns the value of attribute level.



7
8
9
# File 'lib/protobuf/common/logger.rb', line 7

def level
  @level
end

Class Method Details

.configure(options) ⇒ Object

One-line file/level configuration



10
11
12
13
# File 'lib/protobuf/common/logger.rb', line 10

def configure(options)
  self.file = options[:file] if options[:file]
  self.level = options[:level] if options[:level]
end

.instanceObject

Singleton instance



21
22
23
24
25
26
27
28
29
30
# File 'lib/protobuf/common/logger.rb', line 21

def instance
  @__instance ||= begin
    log = nil
    if @file and @level
      log = new(self.file)
      log.level = self.level
    end
    log
  end
end

.reset_device!Object

Use to reset the instance



16
17
18
# File 'lib/protobuf/common/logger.rb', line 16

def reset_device!
  self.file = self.level = @__instance = nil
end