Sha256: a925450b8d036e49e59f2d99fabee73bf28ea9ebe525d319a47b2f30e1c64e3d

Contents?: true

Size: 877 Bytes

Versions: 7

Compression:

Stored size: 877 Bytes

Contents

module Chronicle
  module ETL
    module Logger
      extend self

      DEBUG = 0
      INFO = 1
      WARN = 2
      ERROR = 3
      FATAL = 4
      SILENT = 5

      attr_accessor :log_level

      @log_level = INFO

      def output message, level
        return unless level >= @log_level

        if @progress_bar
          @progress_bar.log(message)
        else
          $stderr.puts(message)
        end
      end

      def fatal(message)
        output(message, FATAL)
      end

      def error(message)
        output(message, ERROR)
      end

      def info(message)
        output(message, INFO)
      end

      def debug(message)
        output(message, DEBUG)
      end

      def attach_to_progress_bar(progress_bar)
        @progress_bar = progress_bar
      end

      def detach_from_progress_bar
        @progress_bar = nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chronicle-etl-0.5.3 lib/chronicle/etl/logger.rb
chronicle-etl-0.5.2 lib/chronicle/etl/logger.rb
chronicle-etl-0.5.1 lib/chronicle/etl/logger.rb
chronicle-etl-0.5.0 lib/chronicle/etl/logger.rb
chronicle-etl-0.4.4 lib/chronicle/etl/logger.rb
chronicle-etl-0.4.3 lib/chronicle/etl/logger.rb
chronicle-etl-0.4.2 lib/chronicle/etl/logger.rb