Sha256: d99887c6ad871f34910a464bed448ca67f9172d07be9f3e258e0dd406af05f89

Contents?: true

Size: 1.16 KB

Versions: 25

Compression:

Stored size: 1.16 KB

Contents

require 'logger'

module IronCore
  module Logger
    def self.logger
      unless @logger
        @logger = ::Logger.new(STDOUT)
        @logger.level = ::Logger::INFO
      end

      @logger
    end

    def self.logger=(logger)
      @logger = logger
    end

    def self.fatal(product, msg, exception_class = nil)
      self.logger.fatal(product) { msg }

      self.raise_exception(msg, exception_class)
    end

    def self.error(product, msg, exception_class = nil)
      self.logger.error(product) { msg }

      self.raise_exception(msg, exception_class)
    end

    def self.warn(product, msg, exception_class = nil)
      self.logger.warn(product) { msg }

      self.raise_exception(msg, exception_class)
    end

    def self.info(product, msg, exception_class = nil)
      self.logger.info(product) { msg }

      self.raise_exception(msg, exception_class)
    end

    def self.debug(product, msg, exception_class = nil)
      self.logger.debug(product) { msg }

      self.raise_exception(msg, exception_class)
    end

    def self.raise_exception(msg, exception_class)
      unless exception_class.nil?
        raise exception_class.new(msg)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
iron_core-1.0.9 lib/iron_core/iron_logger.rb
iron_core-1.0.8 lib/iron_core/iron_logger.rb
iron_core-1.0.7 lib/iron_core/iron_logger.rb
iron_core-1.0.5 lib/iron_core/iron_logger.rb
iron_core-1.0.4 lib/iron_core/iron_logger.rb
iron_core-1.0.3 lib/iron_core/iron_logger.rb
iron_core-1.0.2 lib/iron_core/iron_logger.rb
iron_core-1.0.1 lib/iron_core/iron_logger.rb
iron_core-1.0.0 lib/iron_core/iron_logger.rb
iron_core-0.6.2 lib/iron_core/iron_logger.rb
iron_core-0.6.1 lib/iron_core/iron_logger.rb
iron_core-0.6.0 lib/iron_core/iron_logger.rb
iron_core-0.5.2 lib/iron_core/iron_logger.rb
iron_core-0.5.1 lib/iron_core/iron_logger.rb
iron_core-0.5.0 lib/iron_core/iron_logger.rb
iron_core-0.4.4 lib/iron_core/logger.rb
iron_core-0.4.3 lib/iron_core/logger.rb
iron_core-0.4.2 lib/iron_core/logger.rb
iron_core-0.4.1 lib/iron_core/logger.rb
iron_core-0.4.0 lib/iron_core/logger.rb