* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
*/
class LogManager extends APIModule {
- public function getLogByJobId($jobid) {
+ /**
+ * Get job log by job identifier.
+ *
+ * @param integer $jobid job identifier
+ * @param boolean $show_time show time in job log
+ * @return array job log lines
+ */
+ public function getLogByJobId($jobid, $show_time = false) {
$logs = LogRecord::finder()->findAllByjobid($jobid);
- $joblog = null;
+ $joblog = [];
if(is_array($logs)) {
- $joblog = array();
foreach($logs as $log) {
- $joblog[] = $log->logtext;
+ if ($show_time) {
+ $joblog[] = $log->time . ' ' . $log->logtext;
+ } else {
+ $joblog[] = $log->logtext;
+ }
}
}
return $joblog;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2019 Kern Sibbald
+ * Copyright (C) 2013-2020 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class JobLog extends BaculumAPIServer {
public function get() {
$jobid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
+ $show_time = false;
+ if ($this->Request->contains('show_time') && $this->getModule('misc')->isValidBoolean($this->Request['show_time'])) {
+ $show_time = (bool)$this->Request['show_time'];
+ }
$result = $this->getModule('bconsole')->bconsoleCommand(
$this->director,
array('.jobs')
array_shift($result->output);
$job = $this->getModule('job')->getJobById($jobid);
if (is_object($job) && in_array($job->name, $result->output)) {
- $log = $this->getModule('joblog')->getLogByJobId($job->jobid);
+ $log = $this->getModule('joblog')->getLogByJobId($job->jobid, $show_time);
$log = array_map('trim', $log);
// Output may contain national characters.
$this->output = array_map('utf8_encode', $log);
}
}
}
-
?>