mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
29.52.2018 fcb7fffe9ab6b5d08bae9e7dbd703096b567e3d6
Logs now the error for failed jobs.
2 files modified
8 ■■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/AbstractCommandLineJob.java 4 ●●●● patch | view | raw | blame | history
borgbutler-core/src/test/java/de/micromata/borgbutler/jobs/TestJob.java 4 ●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/AbstractCommandLineJob.java
@@ -34,6 +34,7 @@
    private String description;
    protected ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    protected ByteArrayOutputStream errorOutputStream = new ByteArrayOutputStream();
    protected boolean logError = true;
    protected abstract CommandLine buildCommandLine();
@@ -98,6 +99,9 @@
            log.info(msg + " Done.");
        } catch (Exception ex) {
            result.setStatus(JobResult.Status.ERROR);
            if (logError && !isCancelledRequested() && getStatus() != Status.CANCELLED) {
                log.error("Execution failed for job: '" + commandLineAsString + "': " + ex.getMessage());
            }
            failed();
        }
        result.setResultObject(outputStream.toString(Definitions.STD_CHARSET));
borgbutler-core/src/test/java/de/micromata/borgbutler/jobs/TestJob.java
@@ -20,6 +20,10 @@
        this.time = time;
        this.failOn = failOn;
        this.counterScript = counterScript;
        if (failOn >= 0) {
            // Don't log the error in the log files due to a failed job, because it's intended to force a failed job.
            this.logError = false;
        }
    }
    @Override