Class: ConsoleTransport
- Inherits:
-
Object
- Object
- ConsoleTransport
- 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
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #console_log(level, message) ⇒ Object
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(config = {}) ⇒ ConsoleTransport
constructor
A new instance of ConsoleTransport.
-
#trace(message) ⇒ Object
Define the logging methods.
- #warn(message) ⇒ Object
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
#level ⇒ Object (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 |
#prefix ⇒ Object (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, ) puts "#{}" # 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() console_log('DEBUG', ) end |
#error(message) ⇒ Object
41 42 43 |
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 41 def error() console_log('ERROR', ) end |
#info(message) ⇒ Object
33 34 35 |
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 33 def info() console_log('INFO', ) end |
#trace(message) ⇒ Object
Define the logging methods
25 26 27 |
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 25 def trace() console_log('TRACE', ) end |
#warn(message) ⇒ Object
37 38 39 |
# File 'lib/wingify/packages/logger/transports/console_transport.rb', line 37 def warn() console_log('WARN', ) end |