Add a message to Log File

@param string $message Message text to log
@param string $logType Message Type

@return true
512644
protected static function addLogToFile($message, $logType = 'Unknown')
    {
        //====================================================================//
        // Safety Check
        if (0 == Splash::configuration()->Logging) {
            return true;
        }
        //====================================================================//
        // Detect Log File Directory
        $logfile = dirname(__DIR__).'/splash.log';
        if (defined('SPLASH_DIR') && realpath(SPLASH_DIR)) {
            $logfile = realpath(SPLASH_DIR).'/splash.log';
        }
        //====================================================================//
        // Open Log File
        $filefd = @fopen($logfile, 'a+');
        //====================================================================//
        // Write Log File
        if ($filefd) {
            $message = date('Y-m-d H:i:s').' '.sprintf('%-15s', $logType).$message;
            fwrite($filefd, $message."\n");
            fclose($filefd);
            @chmod($logfile, 0604);
        }

        return true;
    }
1008115
protected function log($message): void
    {
        if ($this->logger !== null) {
            $this->logger->log($message);
        }
    }
920973
function log($message, $type = null, $explicit = false) {
		try {
			$time = date('Y-m-d|H:i:s');
			if ($type === null) {
				$this->appendToFile(date('Y/m/d'), "[$time] $message", $explicit);
			}
			else { // type !== null
				$this->appendToFile($type, "[$time] $message", $explicit);
			}
		}
		catch (\Exception $e) {
			$this->failedLogging($e, $message);
		}
	}
761400
public function addMessage($message) {
        $migrationName = get_class($this);
        $this->messages[] = sprintf("%s:  %s\n", $migrationName, $message);
    }
558669
public function message($message, $type = 'line')
    {
        if (! is_null($this->command)) {
            $this->command->{$type}($message);
        }
    }
1284498
protected function addMessage($message) {
		$hash = crc32(json_encode(func_get_args()));
		
		if (isset($this->_messages[$hash])) {
			return;
		}
		
		if (func_num_args() > 1) {
			$this->_messages[$hash] = call_user_func_array('sprintf', func_get_args());
		} else {
			$this->_messages[$hash] = (string) $message;
		}
	}
246578
private function add ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true)
		{
			$this->_data[] = new Notification ($message, $type, $isRaw, $canHide);
		}
1328175
public function addMessage(Message $message)
    {
        $message->setMessageBroker($this);
        $this->messages->attach($message);
    }
365654
public function log($message)
    {
        if ($this->enabled) {
            $entry = $this->formatMessage($message);
            $fp = fopen($this->file, "a");
            fwrite($fp, $entry . PHP_EOL);
            fclose($fp);
        }
    }
312252
private function logToGlobalFile($message) {
		if($this->globalLogpath != '') {
			$logfile = fopen($this->globalLogpath, "a");
			if($logfile) {
				fwrite($logfile, $message);
				fclose($logfile);
			}
		}
	}
1247910
public function setFieldMessage(
        $fieldName,
        $message,
        $messageType = ValidationResult::TYPE_ERROR,
        $messageCast = ValidationResult::CAST_TEXT
    ) {
        $field = $this->fields->dataFieldByName($fieldName);
        if ($field) {
            $field->setMessage($message, $messageType, $messageCast);
        }
        return $this;
    }
758591
private static function _write($type, $message) {
        $log_path = Config::get('log.folder', LOLLIPOP_STORAGE_LOG);
        $log_enable = Config::get('log.enable', true);
        $log_hourly = Config::get('log.hourly', false);
        
        if (!is_dir($log_path))
           throw new \Lollipop\Exception\Runtime('Log folder doesn\'t exists'); 
        
        if (!is_writeable($log_path))
           throw new \Lollipop\Exception\Runtime('Log folder is not writeable'); 

        if (!isset(self::$_messages[$type]))
            throw new \Lollipop\Exception\Argument('Invalid log type');
        
        // Save to memory
        array_push(self::$_messages[$type], $message);
        
        if ($log_enable && !self::$_busy) {
            self::$_busy = true;
            
            // Create filename base on configuration (daily or hourly)
            $filename = $log_path . DIRECTORY_SEPARATOR . ($log_hourly ? date('Y-m-d-H') : date('Y-m-d')) . '.log';
            
            // Save to file
            file_put_contents($filename, date('Y-m-d H:i:s') . ' [' . strtoupper($type) . '] ' . $message . "\n", FILE_APPEND);
            
            self::$_busy = false;
        }
    }
1042260
public function addMessage(Message $message)
    {
        $type = $message->getType();
        if (!array_key_exists($type, $this->messages)) {
            $this->messages[$type] = [];
        }

        if ($message->getId() !== null) {
            $this->messages[$type][$message->getId()] = $message;
        } else {
            $this->messages[$type][] = $message;
        }

        return $this;
    }
1278533
public function addMessage($message, $type)
    {
        if (!is_string($message)) {
            throw new \InvalidArgumentException('Message must be a string');
        }
        if (!$message) {
            throw new \InvalidArgumentException('Message can\'t be empty');
        }
        if (!is_string($type)) {
            throw new \InvalidArgumentException('Type must be a string');
        }
        if (!$type) {
            throw new \InvalidArgumentException('Type can\'t be empty');
        }
        $this->messages[$type][] = $message;

        return $this;
    }
914942
protected function writeToExceptionLogFile($message)
    {
        if (is_writable($this->exceptionLogFile) || is_writable(dirname($this->exceptionLogFile))) {
            $message = sprintf('[%s] %s' . PHP_EOL, (new \DateTime())->format(\DateTime::ISO8601), $message);
            @file_put_contents($this->exceptionLogFile, $message, FILE_APPEND);
        }
    }
1132537
public function addLog($key, $message)
    {
        if (!is_string($message)) {
            throw new \InvalidArgumentException(sprintf(
                '[%s]: "message" must be type of string, %s given.',
                __METHOD__,
                gettype($message)
            ));
        }

        if (!isset($this->logs[$key])) {
            $this->logs[$key] = [];
        }

        $this->logs[$key][] = $message;

        return $this;
    }
614788
private function logMessage(Message $message)
    {
        $logMessage = \sprintf(
            '%s %s (%.3Fs)',
            $message->getRequest()->getMethod(),
            (string) $message->getRequest()->getUri(),
            $message->getDuration()
        );

        // This is a "simple" log, for general purpose
        $this->logger->log(
            $message->getLogLevel(),
            $logMessage
        );

        // This is a debug log, with all message details, useful for debugging
        $this->logger->debug($logMessage, $message->jsonSerialize());
    }