Skip to content

Commit

Permalink
updating method documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TwP committed Apr 21, 2009
1 parent b7c584d commit e29c1a2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
23 changes: 22 additions & 1 deletion lib/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,28 @@ def appenders
::Logging::Appenders
end

# TODO: document method
# call-seq:
# Logging.consolidate( 'First::Name', 'Second::Name', ... )
#
# Consolidate all loggers under the given namespace. All child loggers
# in the namespace will use the "consolidated" namespace logger instead
# of creating a new logger for each class or module.
#
# If the "root" logger name is passed to this method then all loggers
# will consolidate to the root logger. In other words, only the root
# logger will be created, and it will be used by all classes and moduels
# in the applicaiton.
#
# ==== Example
#
# Logging.consolidate( 'Foo' )
#
# foo = Logging.logger['Foo']
# bar = Logging.logger['Foo::Bar']
# baz = Logging.logger['Baz']
#
# foo.object_id == bar.object_id #=> true
# foo.object_id == baz.object_id #=> false
#
def consolidate( *args )
::Logging::Repository.instance.add_master(*args)
Expand Down
15 changes: 13 additions & 2 deletions lib/logging/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ def parent_name( key )
p
end

# TODO: document method
# call-seq:
# add_master( 'First::Name', 'Second::Name', ... )
#
# Add the given logger names to the list of consolidation masters. All
# classes in the given namespace(s) will use these loggers instead of
# creating their own individual loggers.
#
def add_master( *args )
args.map do |key|
key = to_key(key)
Expand All @@ -176,7 +182,12 @@ def add_master( *args )
end
end

# TODO: document method
# call-seq:
# master_for( key )
#
# Retruns the consolidation master name for the given _key_. If there is
# no consolidation master, then +nil+ is returned.
#
def master_for( key )
return if @masters.empty?
key = to_key(key)
Expand Down

0 comments on commit e29c1a2

Please sign in to comment.