CauseFX 4 лет назад
Родитель
Сommit
d9c7f6515c
1 измененных файлов с 36 добавлено и 0 удалено
  1. 36 0
      api/classes/logger.class.php

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

@@ -0,0 +1,36 @@
+<?php
+
+use Nekonomokochan\PhpJsonLogger\Logger;
+use Nekonomokochan\PhpJsonLogger\LoggerBuilder;
+
+class OrganizrLogger extends LoggerBuilder
+{
+	public $isReady;
+	
+	/**
+	 * @return string
+	 */
+	public function getReadyStatus(): bool
+	{
+		return $this->isReady;
+	}
+	
+	/**
+	 * @param string $traceId
+	 */
+	public function setReadyStatus(bool $readyStatus)
+	{
+		$this->isReady = $readyStatus;
+	}
+	
+	public function build(): Logger
+	{
+		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);
+	}
+}