1. Go to this page and download the library: Download timewave/laravel-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/ */
timewave / laravel-logger example snippets
use Timewave\Logger\Classes\Logger;
use Timewave\Logger\Classes\OtlpSender;
$log = new Logger(
'my-app-name',
'debug',
'text',
"\t",
new OtlpSender('http://localhost:4318')
);
$log->info('Something happened', ['key' => 'value']);
$log = new Logger('auth-4', 'debug', 'text', "\t", new OtlpSender('http://localhost:4318'));
$request = $log->createChildSpan('request', ['requestId' => 'Legodalf'], ['http.method' => 'POST']);
$request->verbose('Incoming request');
$login = $request->createChildSpan('login', ['username' => 'siv']);
$login->info('User is trying to login'); // requestId=Legodalf username=siv traceId=… spanId=…
// The underlying Span is reachable for callers that need the id or trace id
// (e.g. to set on a response header):
$traceId = $login->getSpan()->traceId;
$login->endSpan();
$request->endSpan();
$userId = $request->withChildSpan('login', ['username' => 'siv'], function (Logger $log) {
$log->info('User is trying to login');
return User::login('siv');
});