Sha256: f63efc6d3e33287cb72453d6c03a9d55d64df89325631ef03972a0e34b5dfb80

Contents?: true

Size: 940 Bytes

Versions: 4

Compression:

Stored size: 940 Bytes

Contents

Logging.init :debug, :info, :warn, :error, :fatal unless Logging.const_defined? 'MAX_LEVEL_LENGTH'

module Ixtlan
  class AuditConfig

    @logger = Logging::Logger[self]

    def self.configure(keep, file, categories)
      @@categories = categories
      reconfigure(keep, file)
    end

    def self.reconfigure(keep, file)
      audit_appender = 
        RollingFile.new('audit', 
                        { :filename_base => file, 
                          :keep => keep, 
                          :safe => true, 
                          :layout => Logging::Layouts::Pattern.new(:pattern => "%d %m\n") }
                        )

      @@categories.each do |category|
        logger = Logging::Logger[category]
        logger.remove_appenders('audit')
        logger.add_appenders(audit_appender)
        @logger.debug("setup logger for #{category}")
      end
      @logger.info("initialized audit log . . .")
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ixtlan-0.2.4 lib/ixtlan/audit_config.rb
ixtlan-0.2.3 lib/ixtlan/audit_config.rb
ixtlan-0.2.2 lib/ixtlan/audit_config.rb
ixtlan-0.2.1 lib/ixtlan/audit_config.rb