public function write(LogRecord $record)
    {
        $logLine = array();

        if ($record->time) {
            $timestr = ($this->logLevel >= self::LEVEL_DEBUG) ?
                $this->udate('Y-m-d H:i:s.u T', $record->time) :
                date('Y/m/d h:i:s', $record->time);
            $logLine[] = "[ $timestr ]";
        }

        if ($record->level != null) {
            $logLine[] = self::LEVELS[$record->level];
        }

        $logLine[] = $record->message;

        $message = implode(' ', $logLine) . PHP_EOL;

        if ($this->fp) {
            fwrite($this->fp, $message);
        } else {
            if (isset($GLOBALS['useErrorLog'])) {
                error_log($message);
            } else {
                file_put_contents('php://stderr', $message, FILE_APPEND);
            }
        }

        return $message;
    }