Changeset 455

Show
Ignore:
Timestamp:
01/18/02 14:37:58
Author:
miyagawa
Message:

0.11_01

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Log-Dispatch-Config/trunk/README

    r411 r455  
    44SYNOPSIS 
    55      use Log::Dispatch::Config; 
    6       Log::Dispatch::Config->configure('/path/to/config'); 
     6      Log::Dispatch::Config->configure('/path/to/log.conf'); 
    77 
    88      my $dispatcher = Log::Dispatch::Config->instance; 
     
    1010      $dispatcher->emergency('something *bad* happened!'); 
    1111 
    12       # or the same 
    13       my $dispatcher = Log::Dispatch->instance; 
    14  
    1512      # or if you write your own config parser: 
    1613      use Log::Dispatch::Configurator::XMLSimple; 
     
    1815      my $config = Log::Dispatch::Configurator::XMLSimple->new('log.xml'); 
    1916      Log::Dispatch::Config->configure($config); 
     17 
     18      # automatic reloading conf file, when modified 
     19      Log::Dispatch::Config->configure_and_watch('/path/to/log.conf'); 
    2020 
    2121DESCRIPTION 
     
    149149 
    150150    But in practice, in persistent environment like mod_perl, Singleton 
    151     instance is not so useful. Log::Dispatch::Config defines "instance" 
    152     method so that the object reloads itself when configuration file is 
    153     modified since its last object creation time. 
     151    instance becomes sometimes messy. If you call "configure_and_watch" 
     152    method on Log::Dispatch::Config instead of "configure", "instance" call 
     153    will reload the singleton object when configuration file is modified 
     154    since its last configuration time. 
    154155 
    155156PLUGGABLE CONFIGURATOR 
     
    162163    "CONFIGURATION". 
    163164 
    164     *   Inherit from Log::Dispatch::Configurator. Stub "new" constructor is 
    165         inherited, but you can roll your own with it. 
     165    *   Inherit from Log::Dispatch::Configurator. 
    166166 
    167167          package Log::Dispatch::Configurator::Hardwired; 
    168168          use base qw(Log::Dispatch::Configurator); 
    169  
    170           sub new { 
    171               bless {}, shift; 
    172           } 
    173169 
    174170    *   Implement two required object methods "get_attrs_global" and 
     
    214210          } 
    215211 
    216     *   Implement optional "needs_reload" and "reload" methods. 
    217         "needs_reload" accepts Log::Dispatch::Config instance and should 
    218         return boolean value if the object is stale and needs reloading 
    219         itself
     212    *   Implement optional "needs_reload" and "parse" methods. 
     213        "needs_reload" should return boolean value if the object is stale 
     214        and needs reloading itself. This method will be triggered when you 
     215        configure logging object with "configure_and_watch" method
    220216 
    221217        Stub config file mtime based "needs_reload" method is declared in 
     
    228224          } 
    229225 
    230         If you do not need *singleton-ness*, always return true. 
     226        If you do not need *singleton-ness at all*, always return true. 
    231227 
    232228          sub needs_reload { 1 } 
    233229 
    234         "reload" method is called when "needs_reload" returns true, and 
    235         should return new Configurator instance. Typically you should place 
    236         configuration parsing again on this method, so 
    237         Log::Dispatch::Configurator again declares stub "reload" method that 
    238         clones your object. 
    239  
    240           sub reload { 
    241               my $self = shift; 
    242               my $class = ref $self; 
    243               return $class->new($self->{file}); 
    244           } 
     230        "parse" method should do parsing of the config file. This method is 
     231        called in the first parsing of the config file, and again when 
     232        "needs_reload" returns true. Log::Dispatch::Configurator base class 
     233        has a null "parse" method. 
    245234 
    246235    *   That's all. Now you can plug your own configurator (Hardwired) into 
     
    279268      } 
    280269 
    281     Note that your log caller's namespace should not begin with 
     270    Note that your log caller's namespace should not match against 
    282271    "/^Log::Dispatch/", which makes this module confusing. 
    283272 
     
    290279 
    291280SEE ALSO 
    292     the Log::Dispatch::Configurator::AppConfig manpage, the Log::Dispatch 
    293     manpage, the AppConfig manpage 
    294  
     281    the Log::Dispatch::Config::Category manpage, the 
     282    Log::Dispatch::Configurator::AppConfig manpage, the Log::Dispatch 
     283    manpage, the AppConfig manpage, the POE::Component::Logger manpage 
     284 
  • Log-Dispatch-Config/trunk/lib/Log/Dispatch/Config.pm

    r454 r455  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.12
     5$VERSION = 0.11_01
    66 
    77use Log::Dispatch; 
  • Log-Dispatch-Config/trunk/lib/Log/Dispatch/Config/Category.pm

    r454 r455  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.12
     5$VERSION = 0.11_01
    66 
    77use Log::Dispatch::Config; 
     
    3737    my($class, $name) = @_; 
    3838    return $class->_classname($name)->instance; 
     39} 
     40 
     41sub reload { 
     42    my($class, $name) = @_; 
     43    return $class->_classname($name)->reload; 
    3944} 
    4045 
     
    8792  use base qw(Log::Dispatch::Config); 
    8893 
     94=head1 TODO 
     95 
     96=over 4 
     97 
     98=item * 
     99 
     100Defines default logger for not confgured name. log4j has root for it. 
     101 
     102=cut 
     103 
    89104=head1 AUTHOR 
    90105 
  • Log-Dispatch-Config/trunk/lib/Log/Dispatch/Configurator.pm

    r454 r455  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.12
     5$VERSION = 0.11_01
    66 
    77sub new { 
    88    my($class, $file) = @_; 
    9     my $self = bless { 
     9    bless { 
    1010        file   => $file, 
    1111        _ctime => 0, 
    1212        _watch => 0, 
    1313    }, $class; 
    14     $self; 
    1514} 
    1615 
  • Log-Dispatch-Config/trunk/lib/Log/Dispatch/Configurator/AppConfig.pm

    r454 r455  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.12
     5$VERSION = 0.11_01
    66 
    77use Log::Dispatch::Configurator; 
  • Log-Dispatch-Config/trunk/t/11_category.t

    r454 r455  
    1818is "$bar", "$bar2", 'same instance'; 
    1919 
     20Log::Dispatch::Config::Category->reload('Bar'); 
     21my $bar3 = Log::Dispatch::Config::Category->instance('Bar'); 
     22isnt "$bar2", "$bar3", 'not same instance'; 
     23 
    2024END { unlink 't/log.out' if -e 't/log.out' }