Skip to content

Commit

Permalink
Merge branch 'main' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fink authored and Thomas Fink committed Jan 24, 2025
2 parents 4c688d7 + 0fe45d6 commit 2477ee8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions zmsslim/src/Slim/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,25 @@ protected function configureLogger(string $level, string $identifier): void
App::$log = new Logger($identifier);
$level = $this->parseDebugLevel($level);
$handler = new StreamHandler('php://stderr', $level);
$handler->setFormatter(new JsonFormatter());

// Add processor to include application name
$formatter = new JsonFormatter();

// Add processor to format time_local first
App::$log->pushProcessor(function ($record) {
$record['extra']['application'] = 'zmsslim';
return $record;
return array(
'time_local' => (new \DateTime())->format('Y-m-d\TH:i:sP'),
'client_ip' => $_SERVER['REMOTE_ADDR'] ?? '',
'remote_addr' => $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '',
'remote_user' => '',
'application' => 'zmsslim',
'message' => $record['message'],
'level' => $record['level_name'],
'context' => $record['context'],
'extra' => $record['extra']
);
});

$handler->setFormatter($formatter);
App::$log->pushHandler($handler);
}

Expand Down

0 comments on commit 2477ee8

Please sign in to comment.