PHP code example of mahmoud-mhamed / laravel-logman
1. Go to this page and download the library: Download mahmoud-mhamed/laravel-logman 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/ */
'request_logging' => [
'enabled' => env('LOGMAN_REQUEST_LOGGING', false),
'channel' => 'logman_requests', // auto-created if not defined in config/logging.php
'level' => 'info',
'log_query' => true, // query string params
'log_body' => true, // request body (masked)
'log_headers' => true, // curated set of request headers
'log_response_status' => true, // HTTP status code
'log_response_body' => false, // response body (masked; off by default)
'middleware' => 'global', // 'global' | 'web' | 'api' | ['web','api']
// These three read from env as comma-separated lists (parsed into arrays):
// LOGMAN_REQUEST_METHODS="POST,PUT,DELETE" → limit methods; empty = all
// LOGMAN_REQUEST_ONLY="api/*,checkout" → path allowlist (* wildcards)
// LOGMAN_REQUEST_ONLY_CONTAINING="checkout" → URL substring allowlist
'methods' => [],
'only' => [],
'only_containing' => [],
'body_ignore_methods' => ['GET', 'HEAD', 'OPTIONS'],
'except' => ['telescope*', 'livewire*', '*.js', '*.css', /* ... */],
'max_payload_length' => 8000, // truncate oversized body/query payloads
],
// Logs the current request
logman_log_request();
// Log a specific request (and optionally its response)
logman_log_request($request);
logman_log_request($request, $response);
// Or via the facade
use MahmoudMhamed\Logman\Facades\Logman;
Logman::logRequest(); // current request
Logman::logRequest($request); // a specific request
use MahmoudMhamed\Logman\Facades\Logman;
// Report an exception manually
try {
// risky operation...
} catch (\Throwable $e) {
Logman::logException($e);
}
// Send an info message to all enabled channels
Logman::sendInfo('Deployment completed successfully');
// Log the current HTTP request on demand (see "Request Logging" below).
// Bypasses the enabled switch and skip/allowlist filters.
logman_log_request(); // current request
Logman::logRequest($request); // or a specific request
use MahmoudMhamed\Logman\Channels\ChannelInterface;
class PagerDutyChannel implements ChannelInterface
{
public function sendException(array $payload): void { /* ... */ }
public function sendInfo(string $message, array $context): void { /* ... */ }
}
use MahmoudMhamed\Logman\LogmanService;
LogmanService::registerDriver('pagerduty', PagerDutyChannel::class);