Class: StdLogger

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

Overview

Abstract base class for StdOut and StdErr classes.

Direct Known Subclasses

StdErrLogger, StdOutLogger

Instance Method Summary collapse

Methods inherited from LoggerBase

#to_s

Constructor Details

#initialize(config, output) ⇒ StdLogger

Initializes this object.

Parameters:

  • Output (IO)

    destination



28
29
30
31
# File 'lib/debugtrace/loggers.rb', line 28

def initialize(config, output)
  @config = Common::check_type("config", config, Config)
  @output = output
end

Instance Method Details

Outputs the message.

Parameters:

  • message (String)

    the message to output

Returns:

  • (String)

    the message



36
37
38
39
40
# File 'lib/debugtrace/loggers.rb', line 36

def print(message)
  Common::check_type("message", message, String)
  datetime_str = Time.now().strftime(@config.log_datetime_format)
  @output.puts "#{datetime_str} #{message}"
end