PHP code example of naoray / laravel-github-monolog
1. Go to this page and download the library: Download naoray/laravel-github-monolog 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/ */
// Single channel
Log::channel('github')->error('Something went wrong!');
// Or as part of a stack
Log::stack(['daily', 'github'])->error('Something went wrong!');
'github' => [
// ... basic config from above ...
'deduplication' => [
'time' => 60, // Time window in seconds - how long to wait before creating a new issue
'store' => null, // Uses your default cache store (from cache.default)
'prefix' => 'dedup', // Prefix for cache keys
],
]
'github' => [
// ... basic config from above ...
'buffer' => [
'limit' => 0, // Maximum records in buffer (0 = unlimited, flush on shutdown)
'flush_on_overflow' => true, // When limit is reached: true = flush all, false = remove oldest
],
]
'tracing' => [
'enabled' => true, // Master switch for all tracing
'requests' => true, // Enable request tracing
'route' => true, // Enable route tracing
'user' => true, // Enable user tracing
'queries' => [ // Database query tracing
'enabled' => true,
'limit' => 10, // Maximum number of queries to track
],
'jobs' => true, // Enable job context tracing
'commands' => true, // Enable command context tracing
'outgoing_requests' => [ // Outgoing HTTP request tracing
'enabled' => true,
'limit' => 5, // Maximum number of outgoing requests to track
],
'environment' => true, // Enable environment data collection
'session' => true, // Enable session data collection
'redact' => [ // Data redaction configuration
'headers' => [], // Additional headers to redact (beyond defaults)
'payload_fields' => [], // Additional payload fields to redact (beyond defaults)
'query_bindings' => false, // Whether to redact query bindings
],
]
use Naoray\LaravelGithubMonolog\Tracing\UserDataCollector;
UserDataCollector::setUserDataResolver(function ($user) {
return [
'username' => $user->username,
// Add any other user fields you want to log
];
});
use Monolog\LogRecord;
use Naoray\LaravelGithubMonolog\Deduplication\SignatureGeneratorInterface;
class CustomSignatureGenerator implements SignatureGeneratorInterface
{
public function generate(LogRecord $record): string
{
// Your custom logic to generate a signature
return md5($record->message);
}
}