Class: Protobuf::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/protobuf/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/logger.rb', line 7

def file
  @file
end

.levelObject

Returns the value of attribute level.



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

def level
  @level
end

Class Method Details

.configure(options) ⇒ Object

One-line file/level configuration



18
19
20
21
# File 'lib/protobuf/logger.rb', line 18

def self.configure(options)
  self.file = options.fetch(:file, false)
  self.level = options.fetch(:level, false)
end

.instanceObject

Singleton instance



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/protobuf/logger.rb', line 29

def self.instance
  @__instance ||= begin
    log = nil

    if @file && @level
      log = new(self.file)
      log.level = self.level
    end

    log
  end
end

.reset_device!Object

Use to reset the instance



24
25
26
# File 'lib/protobuf/logger.rb', line 24

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