Class: ConsoleTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/wingify/packages/logger/transports/console_transport.rb

Overview

Copyright 2024-2026 Wingify Software Pvt. Ltd.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ ConsoleTransport

Returns a new instance of ConsoleTransport.



18
19
20
21
22
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 18

def initialize(config = {})
  @config = config
  @level = @config[:level] || 'ERROR'
  @prefix = @config[:prefix] || 'VWO-SDK'  # Ensure `@prefix` is set here
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



16
17
18
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 16

def level
  @level
end

#prefixObject (readonly)

Returns the value of attribute prefix.



16
17
18
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 16

def prefix
  @prefix
end

Instance Method Details

#console_log(level, message) ⇒ Object



45
46
47
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 45

def console_log(level, message)
  puts "#{message}" # Output the log to console
end

#debug(message) ⇒ Object



29
30
31
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 29

def debug(message)
  console_log('DEBUG', message)
end

#error(message) ⇒ Object



41
42
43
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 41

def error(message)
  console_log('ERROR', message)
end

#info(message) ⇒ Object



33
34
35
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 33

def info(message)
  console_log('INFO', message)
end

#trace(message) ⇒ Object

Define the logging methods



25
26
27
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 25

def trace(message)
  console_log('TRACE', message)
end

#warn(message) ⇒ Object



37
38
39
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 37

def warn(message)
  console_log('WARN', message)
end