Files
Orchestar/src/Service/Docker/Logger/LoggerService.php

40 lines
837 B
PHP
Raw Normal View History

<?php
/*
* LoggerService.php 2026-03-27 thomas
*
* Copyright (c) 2026 Thomas Schneider <thomas@inter-mundos.de>
* Alle Rechte vorbehalten.
*/
namespace App\Service\Docker\Logger;
use Symfony\Component\Filesystem\Filesystem;
class LoggerService
{
const string LOG_FILE = 'docker.log';
public function __construct(
protected string $logDir,
){}
public function log(string $message): void
{
new Filesystem()->appendToFile($this->logDir . DIRECTORY_SEPARATOR . self::LOG_FILE, $message . PHP_EOL);
}
public function clearLog(): void
{
new Filesystem()->remove($this->logDir . DIRECTORY_SEPARATOR . self::LOG_FILE);
}
public function getLog(): string
{
return new Filesystem()->readFile($this->logDir . DIRECTORY_SEPARATOR . self::LOG_FILE);
}
}