Sha256: 19ef1a00848bcc15717bd5c838204b4b5981c2c29e285e942fbe84449ff848ec
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'alfa/logger' require 'alfa/config' module Alfa class Application private_class_method :new include Alfa::ClassInheritance inheritable_attributes :config @config = Alfa::Config.new def self.config args=nil return @config if args.nil? @config.merge args end def self.init! @log_file = File.open(File.join(@config[:log][:file]), File::WRONLY | File::APPEND | File::CREAT) @logger = Alfa::Logger.new(@log_file) str = "Application (pid=#{$$}) started at #{DateTime.now}" @logger.info "#{'='*str.length}\n#{str}" @logger.info " PROJECT_ROOT: #{@config[:project_root]}" @logger.info " DOCUMENT_ROOT: #{@config[:document_root]}\n" @log_file.flush ObjectSpace.define_finalizer(@logger, Proc.new {@logger.info "Application (pid=#{$$}) stopped at #{DateTime.now}\n\n"}) @config[:db].each_value { |db| db.loggers = [@logger] } @inited = true end def self.load_database path Kernel.require path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alfa-0.0.2.pre | lib/alfa/application.rb |