Sha256: 3862c58472a6ea609740578843c353142d9c67301a4ddf61f20f7f330f056c51
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'logger' require 'tempfile' require_relative 'base' module NseData module Config # Logger handles configuration specifically for logging. # # It inherits from Base to utilize the hash-like configuration # interface and provides default settings for logging. # # @attr_reader [Logger] logger The Logger instance configured by this class. class Logger < Base # Creates a default temporary log file. def self.default_log_file return $stdout if ENV['NSE_DEV'] temp_file = Tempfile.new(['nse_data', '.log']) temp_file.close # Close the file immediately after creation temp_file.path # Return the file path for the Logger end # Initializes the Logger with a default or custom Logger instance. # # @param logger [Logger] Optional custom Logger instance. def initialize(logger = ::Logger.new(self.class.default_log_file)) super() @logger = logger @settings[:logger] = logger # puts "Log file created at: #{self.class.default_log_file}" end # Retrieves/Sets the Logger instance. attr_accessor :logger end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nse_data-0.1.1 | lib/nse_data/config/logger.rb |
nse_data-0.1.0 | lib/nse_data/config/logger.rb |