fix: Created log file if files does not exist
This commit is contained in:
parent
c302c4653a
commit
728fce1b78
@ -9,16 +9,25 @@ class Logger {
|
||||
private $configs = ['enabled' => false];
|
||||
|
||||
function __construct($configs, $tag) {
|
||||
if (isset($configs['logger'])) {
|
||||
$this->configs = $configs['logger'];
|
||||
if (isset($configs['general']) && isset($configs['general']['logger'])) {
|
||||
$this->configs = $configs['general']['logger'];
|
||||
}
|
||||
if ($this->configs['enabled']) {
|
||||
$this->createLoggerFile();
|
||||
$this->logger = new Monolog($tag);
|
||||
$logLevel = Monolog::getLevels()[$this->configs['level']];
|
||||
$this->logger->pushHandler(new StreamHandler($this->configs['file'], $logLevel));
|
||||
}
|
||||
}
|
||||
|
||||
private function createLoggerFile() {
|
||||
if (!file_exists($this->configs['file'])) {
|
||||
if (!fopen($this->configs['file'], 'w')) {
|
||||
throw new \Exception(sprintf('Could not create logger file %s', $this->configs['file']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function debug($message) {
|
||||
if ($this->configs['enabled']) {
|
||||
$this->logger->debug($message);
|
||||
|
@ -17,7 +17,7 @@ class Taskwarrior implements IStorage {
|
||||
|
||||
public function __construct($console, $configs) {
|
||||
$this->console = $console;
|
||||
$this->configs = $configs['taskwarrior'];
|
||||
$this->configs = $configs['storages']['taskwarrior'];
|
||||
$this->logger = new Logger($configs, 'Taskwarrior');
|
||||
$this->tz = new CarbonTimeZone($configs['general']['timezone']);
|
||||
}
|
||||
@ -81,7 +81,7 @@ class Taskwarrior implements IStorage {
|
||||
}
|
||||
|
||||
if (isset($vtodo->DUE)){
|
||||
$task['due'] = new Carbon($vtodo->DUE->getDateTime()->format(\DateTime::W3C));
|
||||
$task['due'] = new Carbon($vtodo->DUE->getDateTime());
|
||||
}
|
||||
|
||||
if (isset($vtodo->RRULE)) {
|
||||
|
Loading…
Reference in New Issue
Block a user