Sha256: 779f28bc4f93f2d7abb0505afcb4b9cfa28c049ec30db3539e2e7f606e5bd1e3

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

# Author::    Nicolas Despres  <nicolas.despres@gmail.com>.
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
# License::   LGPL
# $Id: /w/fey/uttk/trunk/lib/uttk/logger_factory.rb 8778 2005-09-26T04:34:48.103938Z ertai  $


module Uttk

  class LoggerFactory

    def initialize
      @section_tree = create_section_tree
      @severity_level = Logger::Severity::DEBUG
      @verbosity = Logger::Verbosity.new
      @verbosity_level = 0
      @active_section = []
    end

    attr_accessor :verbosity_level

    attr_accessor :severity_level

    attr_accessor :active_section

    attr_accessor :section_tree

    def create(*a, &b)
      log = Logger.new(*a, &b)
      log.severity_level = @severity_level
      log.verbosity_level = @verbosity_level
      log.section_tree = @section_tree
      log.active_section(true, *@active_section)
      log
    end

    #FIXME: move in another place, in order to separate the Logger from Uttk.
    #FIXME: follow the strategy hierarchy without loading all the classes
    private
    def create_section_tree
      tree = Logger::SectionNode.new('all')
      [ 'strategies' ].each do |dir|
        dir_node = Logger::SectionNode.new(dir)
        tree << dir_node
        (Uttk.dir + dir).each_entry do |p|
          if p.to_s =~ /^(\w+)\.rb$/
            dir_node << Logger::SectionNode.new($1)
          end
        end
      end
      tree
    end

  end # class LoggerFactory

end # module Uttk

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uttk-0.4.5.0 lib/uttk/logger_factory.rb
uttk-0.4.6.2 lib/uttk/logger_factory.rb
uttk-0.4.6.1 lib/uttk/logger_factory.rb