Sha256: 8717a9827efc5cb384fdb79ddca85abc5fba96d7d8f4a606f1a5bcd77af81f8f
Contents?: true
Size: 849 Bytes
Versions: 43
Compression:
Stored size: 849 Bytes
Contents
require 'logger' require 'pathname' 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 log_error e, description = nil message = "#{e.class} #{e.message} #{e.backtrace.join("\n")}" message = "#{description} - #{message}" if description logger.error message 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
43 entries across 43 versions & 1 rubygems