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/logger configuration. If logger is specified, file and level are ignored.

Parameters:

  • options (Hash)

    Hash of options for the logger

  • :logger (Hash)

    a customizable set of options

  • :file (Hash)

    a customizable set of options

  • :level (Hash)

    a customizable set of options



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

def self.configure(options)
  @__instance = options.fetch(:logger, nil)
  self.file = options.fetch(:file, false)
  self.level = options.fetch(:level, false)
end

.instanceObject

Singleton instance



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/protobuf/logger.rb', line 36

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



31
32
33
# File 'lib/protobuf/logger.rb', line 31

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