[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/logger/ -> loggermanager.class.php (sommaire)

\defgroup logger The logger package takes care of providing logging facilities for the pLog API. It is a very simple API but on the other hand, it follows some of the principles establishes by log4j and log4php, with a very similar system of layouts, formatters and appenders.

Poids: 206 lignes (7 kb)
Inclus ou requis:0 fois
Référencé: 2 fois
Nécessite: 0 fichiers

Définit 1 class

LoggerManager:: (6 méthodes):
  LoggerManager()
  _loadLoggerConfig()
  createAppenderInstance()
  addLogger()
  getInstance()
  getLogger()


Classe: LoggerManager  - X-Ref

\ingroup logger

The logger manages a bunch of loggers configured in the config/logging.properties.php file.
By default if no loggers are specified it will create one logger called "default".
In order to define new loggers, the configuration file has to look like this:

<pre>
$config["logger_name"] = Array(
"appender" => "name_of_the_appender_class",
"layout"   => "a pattern definition for the log messages",
"file"     => "file_for_fileappender",
"prio"     => "debug" );
</pre>

Where "logger_name" is the identifer that we will use later on in the call to
LoggerManager::getLogger() later on to retrieve a handle to this particular logger.

The available appenders are: "file", "stdout", "null"
The FileAppender   class writes data to a log file, which must be specified via a
property called "file"
The StdoutAppender class writes data to the console
The NullAppender   does not write data anywhere, it's a "dumb" logger that does nothing.
If you do not want a logfile to be written, but want to safe your
configuration, just change the appender from 'file' to 'null' :-)

Layout formats:
PatternLayout: allows to specify a pattern for our messages. Patterns are specified as follows:
<ul>
<li><b>%c</b>               - the class where message was logged</li>
<li><b>%d</b>               - current date</li>
<li><b>%f</b>               - the file where the message was logged</li>
<li><b>%F</b>               - the function where the message was
logged</li>
<li><b>%l</b>               - the line where the message was logged</li>
<li><b>%m</b>               - the log message</li>
<li><b>%n</b>               - a newline</li>
<li><b>%N</b>               - the level name</li>
<li><b>%p</b>               - the level of priority</li>
<li><b>%r</b>               - a carriage return</li>
<li><b>%t</b>               - a horizontal tab</li>
<li><b>%T</b>               - a unix timestamp (seconds since January 1st, 1970)</li>
</ul>

The available priorities are: error > warn > info

NOTE: There can only be one appender and one layout class per logger.

In order to retrieve a handle to one of our loggers later on in our code, we should use
LoggerManager::getLogger()

<pre>
$log =& LoggerManager::getLogger( "logger_name" );
$log->debug( $message );
...
$log->info( $message );
</pre>
LoggerManager()   X-Ref
Create a new LogManager instance.
This should never be called manually.


_loadLoggerConfig()   X-Ref


createAppenderInstance( $appender, $layout, $properties )   X-Ref
dynamically loads a layout formatter

param: appenderName
return: a qLayout class

addLogger($name, $logger)   X-Ref
Add a logger.
If a logger with the given name already exists, an error will be
reported.

param: string A logger name.
param: Logger A Logger instance.

getInstance()   X-Ref
Retrieve the single instance of LogManager.

return: qLogManager A qLogManager instance.

getLogger($name = "default")   X-Ref
Retrieve a logger.
If a name is not specified, the default logger is returned.

param: string A logger name.
return: Logger A Logger instance, if the given Logger exists, otherwise NULL.



Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics