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/ /vendor/
/output/ /output/
/temp/ /temp/
*.log
config.yml config.yml
composer.phar composer.phar

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

@ -6,7 +6,7 @@ use Symfony\Component\Yaml\Exception\ParseException;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Psr\Log\NullLogger;
class App { class App {
protected Logger $logger; protected Logger $logger;
@ -15,10 +15,12 @@ class App {
function __construct(string $configFile) function __construct(string $configFile)
{ {
$this->config = Yaml::parseFile($configFile); $this->config = Yaml::parseFile($configFile);
$logger = new Logger('app'); $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"); $logger->info("Initialization complete");
$this->logger = $logger; $this->logger = $logger;
} }

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