Sha256: 91ef19713e65f1e9d39052a5bdf7017a71d72d578cb36311c420de47d94e2aa0

Contents?: true

Size: 626 Bytes

Versions: 7

Compression:

Stored size: 626 Bytes

Contents

require 'logger'

module PactBroker

  module Logging

    # Need to make this configurable based on the calling app!
    LOG_DIR = Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'log')).cleanpath
    LOG_FILE_NAME = "#{ENV['RACK_ENV'] || 'development'}.log"

    def self.included(base)
      base.extend(self)
    end

    def logger= logger
      @@logger = logger
    end

    def logger
      @@logger ||= begin
        FileUtils.mkdir_p(LOG_DIR)
        logger = Logger.new(File.join(LOG_DIR, LOG_FILE_NAME))
        logger.level = Logger::DEBUG
        logger
      end
    end
  end

  include Logging
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pact_broker-1.2.0 lib/pact_broker/logging.rb
pact_broker-1.1.0 lib/pact_broker/logging.rb
pact_broker-1.0.0 lib/pact_broker/logging.rb
pact_broker-1.0.0.alpha3 lib/pact_broker/logging.rb
pact_broker-1.0.0.alpha2 lib/pact_broker/logging.rb
pact_broker-1.0.0.alpha1 lib/pact_broker/logging.rb
pact_broker-0.0.10 lib/pact_broker/logging.rb