src/Log/Log.php
public function log($level, $message, array $context = [])
    {
        if (self::$open) {
            if (!isset(self::$levels[$level])) {
                throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
            }

            if (self::$levels[$level] < $this->minLevelIndex) {
                return;
            }

            $log_data = $this ->format($level, $message, $context);

            // 获取日志文件
            $log_file = $this->getLogFile();

            // 创建日志目录
            $is_create = $this->createLogPath(dirname($log_file));
            // 写入日志文件
            if ($is_create) {
                if (Coroutine::getuid() > 0) {
                    // 协程写
                    $this->coWrite($log_file, $log_data);
                } else {
                    $this->syncWrite($log_file, $log_data);
                }
            }
        }
    }
public function log($level, $message, array $context = [])
    {
        if (self::$open) {
            if (!isset(self::$levels[$level])) {
                throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
            }

            if (self::$levels[$level] < $this->minLevelIndex) {
                return;
            }

            $log_data = $this ->format($level, $message, $context);

            // 获取日志文件
            $log_file = $this->getLogFile();

            // 创建日志目录
            $is_create = $this->createLogPath(dirname($log_file));
            // 写入日志文件
            if ($is_create) {
                if (Coroutine::getuid() > 0) {
                    // 协程写
                    $this->coWrite($log_file, $log_data);
                } else {
                    $this->syncWrite($log_file, $log_data);
                }
            }
        }
    }
添加日志。

@param mixed $level
@param string $message
@param array $context