Class: RubyLogger

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

Overview

A logger class that outputs using Ruby Logger.

Defined Under Namespace

Classes: Formatter

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ RubyLogger

Initializes this object.

Parameters:

  • config (Config)

    a configuration object



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

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

Instance Method Details

Outputs the message.

Parameters:

  • message (String)

    The message to output



95
96
97
98
99
# File 'lib/debugtrace/loggers.rb', line 95

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

#to_sString

Returns a string representation of this object.

Returns:

  • (String)

    A string representation of this object



104
105
106
# File 'lib/debugtrace/loggers.rb', line 104

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