Changeset 360

Show
Ignore:
Timestamp:
12/06/01 18:47:01
Author:
miyagawa
Message:

update README

Files:

Legend:

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

    r344 r360  
    66      Log::Dispatch::Config->configure('/path/to/config'); 
    77 
     8      my $dispatcher = Log::Dispatch::Config->instance; 
     9 
     10      # or the same (may be deprecated) 
    811      my $dispatcher = Log::Dispatch->instance; 
    912 
    1013DESCRIPTION 
    11     Log::Dispatch::Config provides a way to configure Log::Dispatch with 
    12     configulation file (in AppConfig format). I mean, this is log4j for Perl, 
    13     not with all API compatibility though. 
     14    Log::Dispatch::Config is a subclass of Log::Dispatch and provides a way 
     15    to configure Log::Dispatch object with configulation file (in AppConfig 
     16    format). I mean, this is log4j for Perl, not with all API compatibility 
     17    though. 
    1418 
    1519METHOD 
    16     This module has one class method `configure' which parses config file and 
    17     declares `instance' method in Log::Dispatch namespace. So what you should 
    18     do is call `configure' method once in somewhere (like `startup.pl' in 
    19     mod_perl), then you can get configured dispatcher instance via 
    20     `Log::Dispatch->instance'. 
     20    This module has a class method `configure' which parses config file for 
     21    later createion of the Log::Dispatch::Config singleton instance. (Actual 
     22    construction of the object is done in the first `instance' call). 
     23 
     24    So, what you should do is call `configure' method once in somewhere 
     25    (like `startup.pl' in mod_perl), then you can get configured dispatcher 
     26    instance via `Log::Dispatch::Config->instance'. 
     27 
     28    Formerly, `configure' method declares `instance' method in Log::Dispatch 
     29    namespace. Now it inherits from Log::Dispatch, so the namespace 
     30    pollution is not necessary. Currrent version still defines one-liner 
     31    shortcut: 
     32 
     33      sub Log::Dispatch::instance { Log::Dispatch::Config->instance } 
     34 
     35    so still you can call `Log::Dispatch::Config->instance', if you prefer, 
     36    or for backward compatibility. 
    2137 
    2238CONFIGURATION 
     
    4460          dispatchers = file screen 
    4561 
    46         `dispatchers' defines logger names, which will be splitted by spaces. 
    47         If this parameter is unset, no logging is done. 
     62        `dispatchers' defines logger names, which will be splitted by 
     63        spaces. If this parameter is unset, no logging is done. 
    4864 
    4965    format 
     
    5571 
    5672          %d ${datetime}        datetime string 
    57           %p ${priority}        priority (debug, indo, warn ...) 
     73          %p ${priority}        priority (debug, info, warning ...) 
    5874          %m ${message}         message string 
    5975          %F ${filename}        filename 
     
    6884 
    6985    Parameters for each dispatcher should be prefixed with "name.", where 
    70     "name" is the name of each one, defined in global `dispatchers' parameter. 
     86    "name" is the name of each one, defined in global `dispatchers' 
     87    parameter. 
    7188 
    7289    class 
    7390          screen.class = Log::Dispatch::Screen 
    7491 
    75         `class' defines class name of Log::Dispatch subclasses. This parameter 
    76         is essential. 
     92        `class' defines class name of Log::Dispatch subclasses. This 
     93        parameter is essential. 
    7794 
    7895    format 
     
    88105          screen.stderr = 1 
    89106 
    90         Other parameters would be passed to the each dispatcher construction. 
    91         See Log::Dispatch::* manpage for the details. 
     107        Other parameters would be passed to the each dispatcher 
     108        construction. See Log::Dispatch::* manpage for the details. 
    92109 
    93110SINGLETON 
    94     Declared `instance' method would make `Log::Dispatch' class singleton, so 
    95     multiple calls of `instance' will all result in returning same object. 
     111    Declared `instance' method would make `Log::Dispatch::Config' class 
     112    singleton, so multiple calls of `instance' will all result in returning 
     113    same object. 
    96114 
    97       my $one = Log::Dispatch->instance; 
    98       my $two = Log::Dispatch->instance; # same as $one 
     115      my $one = Log::Dispatch::Config->instance; 
     116      my $two = Log::Dispatch::Config->instance; # same as $one 
    99117 
    100118    See GoF Design Pattern book for Singleton Pattern. 
    101119 
    102120    But in practice, in persistent environment like mod_perl, Singleton 
    103     instance is not so useful. Log::Dispatch::Config defines `instance' method 
    104     so that the object reloads itself when configuration file is modified 
    105     since its last object creation time. 
     121    instance is not so useful. Log::Dispatch::Config defines `instance' 
     122    method so that the object reloads itself when configuration file is 
     123    modified since its last object creation time. 
    106124 
    107125TODO