1. Go to this page and download the library: Download phputil/logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phputil / logger example snippets
phputil\TextFileLogger;
// It is recommended to set the DateTimeZone when using TextFileLogger.
$logger = new TextFileLogger( 'log.txt', false, new \DateTimeZone( 'America/Sao_Paulo' ) );
$logger->info( 'Something will happen' );
$logger->debug( 'Something happened.' );
$logger->warn( 'Wait!' );
$logger->error( 'Ouch.' );
$logger->log( Logger::DEBUG, "That's awesome!" );
phputil\Logger;
use phputil\TextFileLogger;
use phputil\FakeLogger;
$inDebugMode = true;
$logger = $inDebugMode
? new TextFileLogger( 'log.txt', false, new \DateTimeZone( 'America/Sao_Paulo' ) )
: new FakeLogger();
$logger->info( 'Something will happen' );
try {
throw new \Exception( 'Hummm... something bad happened.' );
} catch ( \Exception $e ) {
// Logs message and trace
$logger->error( 'Ouch, I did not expect that!', $e );
}
$logger->log( Logger::DEBUG, "That's awesome!" );
phputil\EchoLogger;
$logger = new EchoLogger();
$logger->info( 'It can log to the console too!' );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.