crystal.register :logger do if defined?(SILENCE_LOGGER) logger = Logger.new nil else config = crystal[:config] if config and config.root? and File.exist?("#{config.root}/log") logger = ActiveSupport::BufferedLogger.new crystal.config.log_path logger.level = ActiveSupport::BufferedLogger.const_get config.log_level.to_s.upcase logger.auto_flushing = false if crystal.config.production? elsif config and config.test? logger = Logger.new nil elsif config logger = Logger.new STDOUT logger.warn "No log folder!" else logger = Logger.new STDOUT logger.warn "Config not initialized!" end end logger end