helpers/config.rb
# Returns the logging configuration for a given log.
#
# Example usage:
# ```
# logging_configuration = Config.instance.logging_configuration('classname')
# @logger = Logger.new(logging_configuration[:file], logging_configuration[:rotate])
# ```
#
# @raise [ArgumentError] If the logging class does not exist.
#
# @param [String] The log.
# @return [Hash] The logging configuration hash with the file & rotation configuration.
Returns the logging configuration for a given log.
Returns the logging configuration for a given log .
def logging_configuration(log)
        raise Exception.new('You need to load the configuration before using it.') if @config.nil?
        class_name = log
        class_name = class_name.capitalize if class_name =~ /^[a-z]/
        logging_class = get_class(class_name)
        raise ArgumentError.new("Logging class does not exist: #{log}") if logging_class.nil?
        if @config['logs'].nil? || @config['logs'][log].nil?
            return {
                'file': logging_class::DEFAULT_LOGGING_LOCATION,
                'rotate': logging_class::DEFAULT_LOGGING_ROTATION,
            }
        end
        log_file_location = @config['logs'][log]['file']
        log_file_rotation ||= logging_class::DEFAULT_LOGGING_LOCATION
        log_file_rotation = @config['logs'][log]['rotate']
        log_file_rotation ||= logging_class::DEFAULT_LOGGING_ROTATION
        return {
            'file': log_file_location,
            'rotate': log_file_rotation,
        }
    end
def logging_configuration ( log ) raise Exception . new ( 'You need to load the configuration before using it.' ) if @config . nil? class_name = log class_name = class_name . capitalize if class_name =~ / ^[a-z] / logging_class = get_class ( class_name ) raise ArgumentError . new ( "Logging class does not exist: #{log}" ) if logging_class . nil? if @config [ 'logs' ] . nil? || @config [ 'logs' ] [ log ] . nil? return { 'file' : logging_class :: DEFAULT_LOGGING_LOCATION , 'rotate' : logging_class :: DEFAULT_LOGGING_ROTATION , } end log_file_location = @config [ 'logs' ] [ log ] [ 'file' ] log_file_rotation ||= logging_class :: DEFAULT_LOGGING_LOCATION log_file_rotation = @config [ 'logs' ] [ log ] [ 'rotate' ] log_file_rotation ||= logging_class :: DEFAULT_LOGGING_ROTATION return { 'file' : log_file_location , 'rotate' : log_file_rotation , } end
Returns the logging configuration for a given log.
Returns the logging configuration for a given log .
# Capitalize the log if we're given a string that starts with a lowercase letter. # If we don't have a configuration, just return the defaults.
The logging configuration hash with the file & rotation configuration.
The logging configuration hash with the file & rotation configuration .
Hash
[ArgumentError] If the logging class does not exist.
[ ArgumentError ] If the logging class does not exist .
log
<not_specific>
<not_specific>
None
logger
Logger.new(logging_configuration[:file], logging_configuration[:rotate]) ```
Logger . new ( logging_configuration [ : file ] logging_configuration [ : rotate ] ) ` ` `