Interpolate context values into message.

@param string $message
Message string.
@param array $context
Context values.
@return string Interpolated message string.
554336
public static function interpolate($message, array $context = array())
    {
        foreach ($context as $key => $value) {
            $message = str_replace('{' . $key . '}', $value, $message);
        }
        return $message;
    }
767828
public function log($level, $message, array $context = [])
    {
        echo sprintf(
            'LOG: [%s] %s',
            $level,
            $this->interpolate($message, $context)
        ) . PHP_EOL;
    }
783191
public function debug($message, array $context = array())
    {
        if (self::isSetLogger()) {
            return self::$logger->debug($message, $context);
        }

        return false;
    }
1296483
public function info($message, array $context = []): void
    {
        $message = $this->interpolate($message, $context);

        if (!$this->startTime) {
            $this->startTime = $this->timer = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true);
        }

        $curTimer = microtime(true);
        $curMemory = memory_get_usage();

        $key = sprintf(
            '%f :: %f :: %d',
            $curTimer - $this->startTime,
            $curTimer - $this->timer,
            $curMemory - $this->memory
        );

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

        $this->timer = $curTimer;
        $this->memory = $curMemory;
    }
907596
public function beginNotice(string $message, array $context = []) {
        return $this->begin(LogLevel::NOTICE, $message, $context);
    }
39227
protected function buildMessage(array $context): string
    {
        $message = $this->message ?: '{name} took {lapse} seconds.';

        return Str::replace($message, $context);
    }
751468
protected function logDebug($message, array $context = [])
    {
        $this->hasLogger() === true ?: $this->logger->debug($message, $context);
    }
1053587
protected function messageToString($level, $message, array $context)
    {
        if (!empty($context)) {
            $message .= ' '.json_encode($context, JSON_UNESCAPED_UNICODE | JSON_PARTIAL_OUTPUT_ON_ERROR);
        }

        return $message;
    }
131818
public function debug($message, array $context = [])
    {
        $this->log(Doozr_Logging_Constant::DEBUG, $message, $context);

        return $this;
    }
1287015
function (message, context) {
                message = this.messages[message] || message.toString();
                if (context) {
                    $.each(context, function (key, value) {
                        message = message.replace('{' + key + '}', value);
                    });
                }
                return message;
            }
1214652
public function outputHTML($message, $context = [])
    {
        $message = preg_replace_callback('/{([a-z0-9_-]+)}/i', function ($match) use ($context) {
            if (isset($context[$match[1]]) && is_string($context[$match[1]])) {
                return $context[$match[1]];
            }

            // don't change the original message
            return '{'.$match[1].'}';
        }, $message);

        $this->_output_bypass = true;
        $this->sse->send($this->js()->append($message.'<br/>'));
        $this->_output_bypass = false;

        return $this;
    }
1324079
public function info(string $message, array $context = []){
        if($this->logger !== null){
            $this->logger->info($message, $context);
        }

        if($this->messagePanel !== null){
            $this->messagePanel->addMessage($message, LogLevel::INFO);
        }
    }
687422
public function notice($message, array $context = array())
    {
        if ($this->logger) {
            $context = $this->getLoggerContext($context);

            $this->logger->notice($message, $context);
        }
    }
1076237
protected function formatLog($level, $message, $context = array())
    {
        // Format message and content
        $params = $this->formatParams($message, $context);
        $message = $params['message'];
        $context = $params['context'];

        // Format log content
        $content = str_replace(array(
            '%datetime%', '%namespace%', '%level%', '%message%',
        ), array(
            date($this->dateFormat, microtime(true)),
            $this->namespace,
            strtoupper($level),
            $message,
        ), $this->format);

        // Format extra context
        if ($this->context || $context) {
            $content .= print_r($this->context + $context, true) . "\n";
        }

        return $content;
    }
289470
public function warning($message, array $context = array())
    {
        if (self::isSetLogger()) {
            return self::$logger->warning($message, $context);
        }

        return false;
    }
201049
protected function applyContext($message, array $context = array())
    {
        foreach ($context as $key => $value) {
            $key = trim($key, "{}");
            if ($key != 'exception') {
                $message = $this->replaceContext($message, $key, $value);
            }
        }

        return $message;
    }
22644
public function log($level, $message, array $context = array())
    {
        if (!$this->shouldHandle($level)) {
            return false;
        }

        $levelName = is_int($level) ? array_search($level, self::$levels) : $level;
        $message = $this->interpolate(
            array(
                'message' => $message,
                'context' => $context,
                'level' => strtoupper($levelName),
                'datetime' => new \DateTime(),
            )
        );

        $this->write($message);
    }