Sha256: fd08f09e2238094cdda4e97a20281f25e83d7521cbece4a1cd7e351638a15e38

Contents?: true

Size: 488 Bytes

Versions: 7

Compression:

Stored size: 488 Bytes

Contents

module AbAdmin
  module Utils
    module Logger

      class ShortFormatter < ::Logger::Formatter
        def call(severity, time, progname, msg)
          "[#{time.strftime('%Y-%m-%dT%H:%M:%S')}] #{msg}\n"
        end
      end

      def self.for_file(filename)
        logfile = File.open(Rails.root.join('log', filename), 'a+')
        logfile.sync = true
        logger = ::Logger.new(logfile)
        logger.formatter = ShortFormatter.new
        logger
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.3.6 lib/ab_admin/utils/logger.rb
ab_admin-0.3.5 lib/ab_admin/utils/logger.rb
ab_admin-0.3.4 lib/ab_admin/utils/logger.rb
ab_admin-0.3.3 lib/ab_admin/utils/logger.rb
ab_admin-0.3.2 lib/ab_admin/utils/logger.rb
ab_admin-0.3.1 lib/ab_admin/utils/logger.rb
ab_admin-0.3.0 lib/ab_admin/utils/logger.rb