Recommend this page to a friend! |
Classes of Kjell-Inge Gustafsson | PHP Logger Library Depot | README.md | Download |
|
DownloadLoggerDepotis a depot for PHP application/software loggers >making loggers available on demand. Each logger is identified by a unique and fixed (type case-sensitive _string_) key and set and retrieved using the key. You can use namespace as key (ex It is possible to combine fixed key and 'namespaced' loggers in the depot. You may also use different keys for the same logger as well as set a logger as a fallback logger. Invoking of a logger is as easy as The construction makes it possible to supervise loggers for separate parts (functions, modules, components etc) of your software. UsageWith \<logger\> (below) means any PHP logger and \<logConfig\> ) corresponding config.
class LoggerUserClass1 {
} class LoggerUserClass2 {
}
<?php use Kigkonsult\LoggerDepot\LoggerDepot; LoggerDepot::registerLogger( <key>, new <logger>( <logConfig> ));
<?php use Kigkonsult\LoggerDepot\LoggerDepot; if( ! LoggerDepot::isLoggerSet( <key> )) {
}
<?php use Kigkonsult\LoggerDepot\LoggerDepot; $logger = LoggerDepot::getLogger( <key> );
<?php use Kigkonsult\LoggerDepot\LoggerDepot; LoggerDepot::getLogger( <key> )->error( 'Error message' );
<?php namespace Kigkonsult\Example; use Kigkonsult\LoggerDepot\LoggerDepot; LoggerDepot::registerLogger( __NAMESPACE__, new <logger>( <logConfig> ));
<?php namespace Kigkonsult\Example\Impl; use Kigkonsult\LoggerDepot\LoggerDepot; class LoggerUserClass3 {
}
<?php namespace Kigkonsult\Example\Impl; use Kigkonsult\LoggerDepot\LoggerDepot; class LoggerUserClass4 {
}
<?php use Kigkonsult\LoggerDepot\LoggerDepot; LoggerDepot::registerLogger( <key>, new <logger>( <logConfig> )); LoggerDepot::setFallbackLoggerKey( <key> );
<?php use Kigkonsult\LoggerDepot\LoggerDepot; LoggerDepot::registerLogger( <key>, new <logger>( <logConfig> ), true );
<?php use Kigkonsult\LoggerDepot\LoggerDepot; $key = LoggerDepot::getFallbackLoggerKey();
<?php use Kigkonsult\LoggerDepot\LoggerDepot; $keys = LoggerDepot::getLoggerKeys();
<?php use Kigkonsult\LoggerDepot\LoggerDepot; LoggerDepot::unregisterLogger( <key> );
<?php use Kigkonsult\LoggerDepot\LoggerDepot; foreach( LoggerDepot::getLoggerKeys() as $key ) {
}
composer require kigkonsult/loggerdepot:dev-master
{
}
use Kigkonsult\LoggerDepot\LoggerDepot; ... include 'vendor/autoload.php';
use Kigkonsult\LoggerDepot\LoggerDepot; ... include 'pathToSource/loggerdepot/autoload.php';
|