Sha256: 7ec9485a880cf6302bcb916da1f7eaec7fb02ccb19f09a2e1395c4075cfe4c49

Contents?: true

Size: 935 Bytes

Versions: 10

Compression:

Stored size: 935 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

10 entries across 10 versions & 1 rubygems

Version Path
ixtlan-0.4.3 lib/ixtlan/audit_config.rb
ixtlan-0.4.2 lib/ixtlan/audit_config.rb
ixtlan-0.4.1 lib/ixtlan/audit_config.rb
ixtlan-0.4.0 lib/ixtlan/audit_config.rb
ixtlan-0.4.0.pre5 lib/ixtlan/audit_config.rb
ixtlan-0.4.0.pre4 lib/ixtlan/audit_config.rb
ixtlan-0.4.0.pre3 lib/ixtlan/audit_config.rb
ixtlan-0.4.0.pre2 lib/ixtlan/audit_config.rb
ixtlan-0.4.0.pre lib/ixtlan/audit_config.rb
ixtlan-0.3.0 lib/ixtlan/audit_config.rb