![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/textalk/websocket/tests/mock/ |
<?php /** * Simple echo logger (only available when running in dev environment) */ namespace WebSocket; class EchoLog implements \Psr\Log\LoggerInterface { use \Psr\Log\LoggerTrait; public function log($level, $message, array $context = []) { $message = $this->interpolate($message, $context); $context_string = empty($context) ? '' : json_encode($context); echo str_pad($level, 8) . " | {$message} {$context_string}\n"; } public function interpolate($message, array $context = []) { // Build a replacement array with braces around the context keys $replace = []; foreach ($context as $key => $val) { // Check that the value can be cast to string if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { $replace['{' . $key . '}'] = $val; } } // Interpolate replacement values into the message and return return strtr($message, $replace); } }