Sha256: 783f8cb9464df88151ef69ccad0b197673df6ee42be4fefc5ffb23864b72255c

Contents?: true

Size: 774 Bytes

Versions: 21

Compression:

Stored size: 774 Bytes

Contents

module Ddr::Batch
  class Log

    DEFAULT_LOG_DIR = File.join(Rails.root, 'log')

    class << self

      def logger(batch_id)
        loggr = Logger.new(File.open(file_path(batch_id), File::WRONLY | File::APPEND | File::CREAT))
        loggr.level = Ddr::Batch.processor_logging_level
        loggr.datetime_format = "%Y-%m-%d %H:%M:%S.L"
        loggr.formatter = proc do |severity, datetime, progname, msg|
          "#{datetime} #{severity}: #{msg}\n"
        end
        loggr
      end

      def clear_log(batch_id)
        log_file_path = file_path(batch_id)
        FileUtils.remove(log_file_path) if File.exists?(log_file_path)
      end

      def file_path(batch_id)
        File.join(DEFAULT_LOG_DIR, "batch_#{batch_id}_log.txt")
      end

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
ddr-batch-1.7.2 app/models/ddr/batch/log.rb
ddr-batch-1.7.1 app/models/ddr/batch/log.rb
ddr-batch-1.7.0 app/models/ddr/batch/log.rb
ddr-batch-1.6.1 app/models/ddr/batch/log.rb
ddr-batch-1.6.0 app/models/ddr/batch/log.rb
ddr-batch-1.6.0.rc1 app/models/ddr/batch/log.rb
ddr-batch-1.5.1 app/models/ddr/batch/log.rb
ddr-batch-1.5.0 app/models/ddr/batch/log.rb
ddr-batch-1.5.0.rc1 app/models/ddr/batch/log.rb
ddr-batch-1.4.1 app/models/ddr/batch/log.rb
ddr-batch-1.4.0 app/models/ddr/batch/log.rb
ddr-batch-1.4.0.rc1 app/models/ddr/batch/log.rb
ddr-batch-1.3.0 app/models/ddr/batch/log.rb
ddr-batch-1.3.0.rc1 app/models/ddr/batch/log.rb
ddr-batch-1.2.0 app/models/ddr/batch/log.rb
ddr-batch-1.2.0.rc6 app/models/ddr/batch/log.rb
ddr-batch-1.2.0.rc5 app/models/ddr/batch/log.rb
ddr-batch-1.2.0.rc4 app/models/ddr/batch/log.rb
ddr-batch-1.2.0.rc3 app/models/ddr/batch/log.rb
ddr-batch-1.2.0.rc2 app/models/ddr/batch/log.rb