Class: LogManager

Inherits:
VWOLogger show all
Defined in:
lib/wingify/packages/logger/core/log_manager.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ LogManager

Returns a new instance of LogManager.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 34

def initialize(config = {})
  # Store the config in an instance variable
  @config = config
  
  # Initialize default config values inside @config
  @config[:name] ||= 'VWO Logger'
  @config[:request_id] ||= SecureRandom.uuid
  @config[:level] ||= 'ERROR'
  @config[:prefix] ||= 'VWO-SDK'
  @config[:date_time_format] ||= lambda { Time.now.iso8601 }
  
  # Initialize the transport manager with the @config hash
  @transport_manager = LogTransportManager.new(@config)
  handle_transports
end

Class Method Details

.instance(config = {}) ⇒ Object

Use the ‘instance` method to initialize and get the instance



26
27
28
29
30
31
32
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 26

def self.instance(config = {})
    # If an instance already exists, return it
    if @instance.nil?
    @instance = new(config)
    end
    @instance
end

Instance Method Details

#debug(message) ⇒ Object



54
55
56
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 54

def debug(message)
  @transport_manager.log('DEBUG', message)
end

#error(message, extraData = {}) ⇒ Object



66
67
68
69
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 66

def error(message, extraData = {})
  @transport_manager.log('ERROR', message)
  # sendLogToVWO(message, LogLevelEnum::ERROR, extraData)
end

#info(message) ⇒ Object



58
59
60
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 58

def info(message)
  @transport_manager.log('INFO', message)
end

#trace(message) ⇒ Object



50
51
52
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 50

def trace(message)
  @transport_manager.log('TRACE', message)
end

#warn(message) ⇒ Object



62
63
64
# File 'lib/wingify/packages/logger/core/log_manager.rb', line 62

def warn(message)
  @transport_manager.log('WARN', message)
end