refactor: documents
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -40,11 +40,18 @@ class FileLogger implements LoggerInterface
|
||||
|
||||
public function log($level, $message, array $context = []): void
|
||||
{
|
||||
$timestamp = $this->formatTimestamp();
|
||||
$interpolated = $this->interpolate((string)$message, $context);
|
||||
// Extract tenant id injected by TenantAwareLogger; default to 'system'.
|
||||
$tenantId = isset($context['__tenant']) && is_string($context['__tenant'])
|
||||
? $context['__tenant']
|
||||
: 'system';
|
||||
unset($context['__tenant']);
|
||||
|
||||
$timestamp = $this->formatTimestamp();
|
||||
$interpolated = $this->interpolate((string) $message, $context);
|
||||
$payload = [
|
||||
'time' => $timestamp,
|
||||
'level' => strtolower((string)$level),
|
||||
'time' => $timestamp,
|
||||
'level' => strtolower((string) $level),
|
||||
'tenant' => $tenantId,
|
||||
'channel' => $this->channel,
|
||||
'message' => $interpolated,
|
||||
'context' => $this->sanitizeContext($context),
|
||||
@@ -53,11 +60,12 @@ class FileLogger implements LoggerInterface
|
||||
if ($json === false) {
|
||||
// Fallback stringify if encoding fails (should be rare)
|
||||
$json = json_encode([
|
||||
'time' => $timestamp,
|
||||
'level' => strtolower((string)$level),
|
||||
'channel' => $this->channel,
|
||||
'message' => $interpolated,
|
||||
'context_error' => 'failed to encode context: '.json_last_error_msg(),
|
||||
'time' => $timestamp,
|
||||
'level' => strtolower((string) $level),
|
||||
'tenant' => $tenantId,
|
||||
'channel' => $this->channel,
|
||||
'message' => $interpolated,
|
||||
'context_error' => 'failed to encode context: ' . json_last_error_msg(),
|
||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?: '{"error":"logging failure"}';
|
||||
}
|
||||
$this->write($json);
|
||||
|
||||
Reference in New Issue
Block a user