lib/gitdocs.rb in gitdocs-0.5.0 vs lib/gitdocs.rb in gitdocs-0.6.0

- old
+ new

@@ -1,41 +1,79 @@ # -*- encoding : utf-8 -*- require 'thread' require 'dante' require 'socket' -require 'shell_tools' -require 'guard' require 'grit' require 'rugged' require 'table_print' +require 'notiffany' +require 'launchy' +require 'celluloid' +require 'listen' +require 'reel/rack' require 'gitdocs/version' +require 'gitdocs/initializer' +require 'gitdocs/share' require 'gitdocs/configuration' -require 'gitdocs/runner' -require 'gitdocs/server' require 'gitdocs/cli' require 'gitdocs/manager' +require 'gitdocs/synchronizer' require 'gitdocs/notifier' +require 'gitdocs/git_notifier' require 'gitdocs/repository' require 'gitdocs/repository/path' +require 'gitdocs/repository/committer' +require 'gitdocs/settings_app' +require 'gitdocs/browser_app' require 'gitdocs/search' module Gitdocs - DEBUG = ENV['DEBUG'] + # @return [String] + def self.log_path + File.expand_path('log', Initializer.root_dirname) + end - # Gitdocs.start(:config_root => "...", :debug => true) - def self.start(options = {}, &blk) - options = { debug: DEBUG, config_root: nil }.merge(options) - @manager.stop if @manager - @manager = Manager.new(options[:config_root], options[:debug], &blk) - @manager.start(options[:port]) + # @param [String] message + # @return [void] + def self.log_debug(message) + init_log + Celluloid.logger.debug(message) end - def self.restart - @manager.restart + # @param [String] message + # @return [void] + def self.log_info(message) + init_log + Celluloid.logger.info(message) end - def self.stop - @manager.stop + # @param [String] message + # @return [void] + def self.log_warn(message) + init_log + Celluloid.logger.warn(message) + end + + # @param [String] message + # @return [void] + def self.log_error(message) + init_log + Celluloid.logger.error(message) + end + + ############################################################################## + + private_class_method + + # @return [void] + def self.init_log + return if @initialized + + # Initialize the logger + log_output = Initializer.foreground ? STDOUT : log_path + Celluloid.logger = Logger.new(log_output) + Celluloid.logger.level = Initializer.verbose ? Logger::DEBUG : Logger::INFO + @initialized = true end end