Class: Maze::Loggers::FileLogger

Inherits:
Logger
  • Object
show all
Includes:
Singleton
Defined in:
lib/maze/loggers/file_logger.rb

Overview

A logger to file, always logging at TRACE level

Constant Summary collapse

LOG_LOCATION =
'maze-runner.log'

Instance Attribute Summary collapse

Attributes inherited from Logger

#file_logger, #stdout_logger

Instance Method Summary collapse

Methods inherited from Logger

#method_missing

Constructor Details

#initializeFileLogger

Returns a new instance of FileLogger.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/maze/loggers/file_logger.rb', line 16

def initialize
  # Remove the previous log file if it exists
  File.delete(LOG_LOCATION) if File.exist?(LOG_LOCATION)

  super(LOG_LOCATION, level: ::Logger::TRACE)

  @datetime_format = '%H:%M:%S'

  @formatter = proc do |severity, time, _name, message|
    formatted_time = time.strftime(@datetime_format)

    "\e[2m[#{formatted_time}]\e[0m #{severity.rjust(5)}: #{message}\n"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Maze::Loggers::Logger

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



14
15
16
# File 'lib/maze/loggers/file_logger.rb', line 14

def datetime_format
  @datetime_format
end