Class: RubyLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/debugtrace/loggers.rb

Overview

A logger class that outputs using the logging library.

Defined Under Namespace

Classes: Formatter

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ RubyLogger

Returns a new instance of RubyLogger.



75
76
77
78
79
80
81
# File 'lib/debugtrace/loggers.rb', line 75

def initialize(config)
  @config = Common::check_type("config", config, Config)
  @logger = Logger.new(
      @config.log_path,
      formatter: Formatter.new(@config),
      datetime_format: @config.logging_datetime_format)
end

Instance Method Details

Outputs the message.

Parameters:

  • message (String)

    The message to output



85
86
87
88
# File 'lib/debugtrace/loggers.rb', line 85

def print(message)
  Common::check_type("message", message, String)
  @logger.log(Logger::Severity::DEBUG, message, 'DebugTrace-rb')
end

#to_sString

Returns a string representation of this object.

Returns:

  • (String)

    A string representation of this object



92
93
94
# File 'lib/debugtrace/loggers.rb', line 92

def to_s
  "Ruby #{Logger.name} path: #{@config.log_path}"
end