1. Go to this page and download the library: Download devnav2902/utilitylog 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/ */
devnav2902 / utilitylog example snippets
UtilityLog::writeLog('error', 'Foo');
UtilityLog::writeLog('info', 'Bar');
// in try-catch block
try {
throw new \Exception('Something happened!');
} catch (\Throwable $th) {
UtilityLog::writeLog('error', 'Error in try-catch block', $th);
}
// contextual information
UtilityLog::writeLog('info', 'User {id} failed to login.', null, ['id' => $user->id]);
class CustomizeFormatter
{
/**
* Customize the given logger instance.
*/
public function __invoke(Logger $logger): void
{
foreach ($logger->getHandlers() as $handler) {
$lineFormatter = new LineFormatter(
config('utilitylog.customize_formatter'),
config('utilitylog.date_format'),
config('utilitylog.allow_inline_linebreaks'),
config('utilitylog.ignore_empty_context_and_extra'),
config('utilitylog.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.