Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/logreader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-07-04 15:56:51 +0300
committerRobin Appelman <robin@icewind.nl>2017-07-04 15:56:51 +0300
commit3d6eb53555a29affef2d65588e17d7d64618aacc (patch)
tree684c486a386e283550a719c01bcab0e5ec483447 /lib
parentae1dd75dfea6813f6ad5e56d54c03020e212b138 (diff)
use the correct timezone when parsing log times
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/LogController.php3
-rw-r--r--lib/Log/LogIterator.php8
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/Controller/LogController.php b/lib/Controller/LogController.php
index 6f5b150..4a97e25 100644
--- a/lib/Controller/LogController.php
+++ b/lib/Controller/LogController.php
@@ -49,12 +49,13 @@ class LogController extends Controller {
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());
}
diff --git a/lib/Log/LogIterator.php b/lib/Log/LogIterator.php
index 224fd05..4d7f708 100644
--- a/lib/Log/LogIterator.php
+++ b/lib/Log/LogIterator.php
@@ -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();
}
@@ -71,7 +75,7 @@ class LogIterator implements \Iterator {
function current() {
$entry = json_decode($this->lastLine, true);
if ($this->dateFormat !== \DateTime::ATOM) {
- $time = \DateTime::createFromFormat($this->dateFormat, $entry['time']);
+ $time = \DateTime::createFromFormat($this->dateFormat, $entry['time'], $this->timezone);
if ($time) {
$entry['time'] = $time->format(\DateTime::ATOM);
}