Browse Source

remove setFileName from logger class if log is not ready
added function tempLogIfNeeded to be able to set a temp log filename if log is not ready

CauseFX 4 years ago
parent
commit
c878baf341
2 changed files with 10 additions and 2 deletions
  1. 0 1
      api/classes/logger.class.php
  2. 10 1
      api/functions/log-functions.php

+ 0 - 1
api/classes/logger.class.php

@@ -28,7 +28,6 @@ class OrganizrLogger extends LoggerBuilder
 		if (!$this->isReady) {
 			$this->setChannel(self::DEFAULT_CHANNEL);
 			$this->setLogLevel(self::INFO);
-			$this->setFileName('/tmp/organizr-temp.log');
 			$this->setMaxFiles(1);
 		}
 		return new Logger($this);

+ 10 - 1
api/functions/log-functions.php

@@ -224,7 +224,7 @@ trait LogFunctions
 		$loggerBuilder = new OrganizrLogger();
 		$loggerBuilder->setReadyStatus($this->hasDB() && $this->log);
 		$loggerBuilder->setMaxFiles($this->config['maxLogFiles']);
-		$loggerBuilder->setFileName($this->log);
+		$loggerBuilder->setFileName($this->tempLogIfNeeded());
 		$loggerBuilder->setTraceId($username);
 		$loggerBuilder->setChannel(ucwords(strtolower($channel)));
 		switch ($this->config['logLevel']) {
@@ -273,6 +273,15 @@ trait LogFunctions
 		
 	}
 	
+	public function tempLogIfNeeded()
+	{
+		if (!$this->log) {
+			return $this->randString() . '.log';
+		} else {
+			return $this->log;
+		}
+	}
+	
 	public function getLog($pageSize = 10, $offset = 0, $filter = 'NONE', $number = 0)
 	{
 		if ($this->log) {