Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Controller/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ public function __construct($appName,

private function getLogIterator() {
$dateFormat = $this->config->getSystemValue('logdateformat', \DateTime::ATOM);
$timezone = $this->config->getSystemValue('logtimezone', 'UTC');
$logClasses = ['\OC\Log\Owncloud', '\OC_Log_Owncloud', '\OC\Log\File'];
foreach ($logClasses as $logClass) {
if (class_exists($logClass)) {
$handle = fopen($logClass::getLogFilePath(), 'rb');
if ($handle) {
return new LogIterator($handle, $dateFormat);
return new LogIterator($handle, $dateFormat, $timezone);
} else {
throw new \Exception("Error while opening ".$logClass::getLogFilePath());
}
Expand Down
12 changes: 9 additions & 3 deletions lib/Log/LogIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ class LogIterator implements \Iterator {
*/
private $dateFormat;

private $timezone;

const CHUNK_SIZE = 100; // how many chars do we try at once to find a new line

/**
* @param resource $handle
* @param string $dateFormat
* @param string $timezone
*/
public function __construct($handle, $dateFormat) {
public function __construct($handle, $dateFormat, $timezone) {
$this->handle = $handle;
$this->dateFormat = $dateFormat;
$this->timezone = new \DateTimeZone($timezone);
$this->rewind();
$this->next();
}
Expand All @@ -71,8 +75,10 @@ function rewind() {
function current() {
$entry = json_decode($this->lastLine, true);
if ($this->dateFormat !== \DateTime::ATOM) {
$time = \DateTime::createFromFormat($this->dateFormat, $entry['time']);
$entry['time'] = $time->format(\DateTime::ATOM);
$time = \DateTime::createFromFormat($this->dateFormat, $entry['time'], $this->timezone);
if ($time) {
$entry['time'] = $time->format(\DateTime::ATOM);
}
}
return $entry;
}
Expand Down