Sha256: d13d218cafd5294fe024aea6f295a956de97054fc8ddb72ef772688dc6171e00
Contents?: true
Size: 1.43 KB
Versions: 9
Compression:
Stored size: 1.43 KB
Contents
require 'active_support/core_ext' module EventBus def self.set_up_logging base_logdir = ENV['EVENTBUS_LOGDIR'] if base_logdir.nil? base_logdir = File.join(ENV['HOME'], "logs", self.PROD_LEVEL, "eventbus", self.application_id) end FileUtils.mkdir_p(base_logdir) unless File.directory?(base_logdir) filename = [File.basename($PROGRAM_NAME, File.extname($PROGRAM_NAME)), ".log"].join logfile_path = File.join(base_logdir, filename) shift_age = ENV['EVENTBUS_LOG_SHIFT_AGE'] || "daily" shift_size = ENV['EVENTBUS_LOG_SHIFT_SIZE'] || 20971520 # 20MB puts "Logging to #{logfile_path}." self.logger = Logger.new(logfile_path, shift_age, shift_size) logger.info "Logging initialized. Rotation age: #{shift_age} Rotation size: #{shift_size}" end # CONSTANTS # True Constants mattr_accessor :CORE_APPLICATION_ID mattr_accessor :DEFAULT_APPLICATION_ID mattr_accessor :DEFAULT_PROD_LEVEL self.CORE_APPLICATION_ID = "EVENTBUS_CORE" self.DEFAULT_APPLICATION_ID = self.CORE_APPLICATION_ID self.DEFAULT_PROD_LEVEL = "development" # Calculated Constants mattr_accessor :PROD_LEVEL self.PROD_LEVEL = ENV['EVENTBUS_PROD_LEVEL'] || self.DEFAULT_PROD_LEVEL # VARIABLES mattr_accessor :application_id self.application_id = ENV['EVENTBUS_APPLICATION_ID'] || self.DEFAULT_APPLICATION_ID mattr_accessor :logger self.set_up_logging end
Version data entries
9 entries across 9 versions & 1 rubygems