PHP code example of hgati / logger

1. Go to this page and download the library: Download hgati/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/ */

    

hgati / logger example snippets


\CleatSquad\Logger::log('Hello!!', 'test.log');
\CleatSquad\Logger::log('Hello!!', 'test.log', \Monolog\Logger::WARNING);
\CleatSquad\Logger::log([22 => 'is an array'], 'test.log');
\CleatSquad\Logger::info(['is an array'], 'test.log');

try {
    throw new \Exception('Error message');
} catch (\Exception $exception) {
    \CleatSquad\Logger::critical($exception);
}

_log('Hello!!', 'test.log');
_log('Hello!!', 'test.log', \Monolog\Logger::WARNING);
_log([22 => 'is an array'], 'test.log');
_log(['is an array'], 'test.log', \Monolog\Logger::INFO);

try {
    throw new \Exception('Error message');
} catch (\Exception $exception) {
    _log($exception);
}

[2021-11-21 14:17:44] logger.DEBUG: Hello!! [] []
[2021-11-21 14:17:44] logger.WARNING: Hello!! [] []
[2021-11-21 14:17:44] logger.DEBUG: Array (  [22] => is an array )  [] []
[2021-11-21 14:17:44] logger.INFO: Array (  [0] => is an array )  [] []

[2021-11-21 14:22:40] logger.CRITICAL: Exception: Error message in /var/www/html/pub/index.php:37 Stack trace: #0 {main} [] []