Sha256: f8e4c683ebc40b657b74e66450a850fe66ddc84f0b96c9b58ea3df5939450d4f

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'logging'
include Logging.globally

module RepoManager
  module Logger

    class Manager

      def initialize(config_filename=nil, yaml_key=nil, configuration={})

        options = configuration[:options] || {}

        if config_filename && yaml_key && configuration.has_key?(yaml_key)
          Logging::Config::YamlConfigurator.load(config_filename, yaml_key.to_s)
        else
          # setup a default root level STDOUT logger
          format = {:pattern => '%-5l %c: %m\n'}
          format = format.merge(:color_scheme => 'default') if options[:color]
          Logging.appenders.stdout('stdout', :layout => Logging.layouts.pattern(format), :level => :info)
          Logging.logger.root.add_appenders('stdout')
        end

        # if verbose, all defined loggers are set to debug level
        if options[:verbose]
          Logging.appenders.each do |appender|
            appender.level = :debug
          end
        end

        # debug
        #Logging.show_configuration
        #logger.error "error"
        #logger.warn "warn"
        #logger.info "info"
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
repo_manager-0.7.3 lib/repo_manager/logger.rb
repo_manager-0.7.2 lib/repo_manager/logger.rb
repo_manager-0.7.1 lib/repo_manager/logger.rb