Sha256: c199a69272d55f3cc5ec2a2a53709f35a7f5e914ad59235187855bed022c04a7

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 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 @ui_element
          @ui_element.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_ui(ui_element)
        @ui_elemenet = ui_element
      end

      def detach_from_ui
        @ui_element = nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronicle-etl-0.5.4 lib/chronicle/etl/logger.rb