Logging
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Jens True 2023-05-31 14:42:43 +00:00
parent 4057581b94
commit 65ac999075
4 changed files with 7 additions and 7 deletions

1
.gitignore vendored

@ -1,5 +1,6 @@
/vendor/
/output/
/temp/
*.log
config.yml
composer.phar

@ -1,8 +1,7 @@
notification:
domain: ntfy.jcktrue.dk
topic: backup
logging:
stream: output.log
log: output.log
rclone:
bwlimit: 6M
backup:

@ -6,7 +6,7 @@ use Symfony\Component\Yaml\Exception\ParseException;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Psr\Log\NullLogger;
class App {
protected Logger $logger;
@ -15,10 +15,12 @@ class App {
function __construct(string $configFile)
{
$this->config = Yaml::parseFile($configFile);
$logger = new Logger('app');
$logger->pushHandler(new StreamHandler($this->getConfig()['logging']['stream']));
if(isset($this->config['log'])) {
$logger->pushHandler(new StreamHandler($this->getConfig()['log']));
}
$logger->info("Initialization complete");
$this->logger = $logger;
}

@ -27,8 +27,6 @@ class CommandBackup extends Command
{
$io = new SymfonyStyle($input, $output);
$io->title('Start backup process');
$io->info('Opening: '.$input->getArgument('config'));
try {
$app = new App($input->getArgument('config'));