Class: Aspisec::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib-ruby/aspisec/logger.rb

Overview

CLI / Terminal / console information logging

Constant Summary collapse

LOG_LEVEL =

Mapping integers to log levels from tty-logger (https://github.com/piotrmurach/tty-logger?tab=readme-ov-file#22-levels)

{
  0 => :debug,
  1 => :info,
  2 => :warn,
  3 => :error,
  4 => :fatal
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_level = 2) ⇒ Logger

Returns a new instance of Logger.

Examples:

logger = Aspisec::Logger.new(0).logger
conf = Aspisec::Config.new(logger)

Parameters:

  • log_level (Integer) (defaults to: 2)

    Default is 2. See LOG_LEVEL.



25
26
27
# File 'lib-ruby/aspisec/logger.rb', line 25

def initialize(log_level = 2)
  @logger = TTY::Logger.new { |config| config.level = LOG_LEVEL[log_level] }
end

Instance Attribute Details

#loggerTTY::Logger (readonly)

The configuration of the logger

Returns:

  • (TTY::Logger)


19
20
21
# File 'lib-ruby/aspisec/logger.rb', line 19

def logger
  @logger
end