refactor(logging): update context manager and log path configuration

- Replace `environment` with `type` for global context data
- Update default log directory path from `storage/logs` to `logs`
- Comment out Nginx log paths to disable by default
- Change `DockerJsonHandler` contract from `FormattableHandler` to `LogHandler`
This commit is contained in:
2025-11-03 01:43:38 +01:00
parent d90f4386d9
commit 6d355c9897
3 changed files with 6 additions and 6 deletions

View File

@@ -5,9 +5,9 @@ declare(strict_types=1);
namespace App\Framework\Logging\Handlers;
use App\Framework\Config\Environment;
use App\Framework\Logging\FormattableHandler;
use App\Framework\Logging\Formatter\JsonFormatter;
use App\Framework\Logging\Formatter\LogFormatter;
use App\Framework\Logging\LogHandler;
use App\Framework\Logging\LogLevel;
use App\Framework\Logging\LogRecord;
use App\Framework\Logging\Security\SensitiveDataRedactor;
@@ -34,7 +34,7 @@ use App\Framework\Logging\Security\SensitiveDataRedactor;
* - docker logs <container> 2>&1 | jq 'select(.level == "ERROR")'
* - docker logs <container> 2>&1 | jq -r '[.timestamp, .level, .message] | @tsv'
*/
final readonly class DockerJsonHandler implements FormattableHandler
final readonly class DockerJsonHandler implements LogHandler
{
private JsonFormatter $formatter;
private LogLevel $minLevel;

View File

@@ -29,7 +29,7 @@ final class LogConfig
$this->pathProvider = $pathProvider;
// Basis-Logverzeichnis (storage/logs für moderne PHP Framework Convention)
$logBasePath = 'storage/logs';
$logBasePath = 'logs';
// Standard-Logpfade definieren
$this->logPaths = [
@@ -38,8 +38,8 @@ final class LogConfig
'error' => $this->resolvePath($logBasePath . '/app/error.log'),
// Systemlogs
'nginx_access' => '/var/log/nginx/access.log',
'nginx_error' => '/var/log/nginx/error.log',
#'nginx_access' => '/var/log/nginx/access.log',
#'nginx_error' => '/var/log/nginx/error.log',
// Sicherheitslogs
'security' => $this->resolvePath($logBasePath . '/security/security.log'),

View File

@@ -90,7 +90,7 @@ final readonly class LoggerInitializer
// Globalen Kontext mit App-Informationen initialisieren
$contextManager->addGlobalData('app_version', $config->app->version);
$contextManager->addGlobalData('environment', $config->app->environment->value);
$contextManager->addGlobalData('environment', $config->app->type->value);
$contextManager->addGlobalTags('application', 'framework');
}
}