Server : Apache System : Linux pod-100823:apache2_74:v0.5.7 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33.7 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system Directory : /nas/content/live/attorneyexperi/wp-content/plugins/ugslot/Monolog/Formatter/ |
<?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Formats incoming records into an HTML table * * This is especially useful for html email logging * * @author Tiago Brito <tlfbrito@gmail.com> */ class Monolog_Formatter_HtmlFormatter extends Monolog_Formatter_NormalizerFormatter { /** * Translates Monolog log levels to html color priorities. */ private $logLevels = array( Monolog_Logger::DEBUG => '#cccccc', Monolog_Logger::INFO => '#468847', Monolog_Logger::NOTICE => '#3a87ad', Monolog_Logger::WARNING => '#c09853', Monolog_Logger::ERROR => '#f0ad4e', Monolog_Logger::CRITICAL => '#FF7708', Monolog_Logger::ALERT => '#C12A19', Monolog_Logger::EMERGENCY => '#000000', ); /** * @param string $dateFormat The format of the timestamp: one supported by DateTime::format */ public function __construct($dateFormat = null) { parent::__construct($dateFormat); } /** * Creates an HTML table row * * @param string $th Row header content * @param string $td Row standard cell content * * @return string */ private function addRow($th, $td = ' ') { $th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8'); $td = '<pre>'.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'</pre>'; return "<tr style=\"padding: 4px;spacing: 0;text-align: left;\">\n<th style=\"background: #cccccc\" width=\"100px\">$th:</th>\n<td style=\"padding: 4px;spacing: 0;text-align: left;background: #eeeeee\">".$td."</td>\n</tr>"; } /** * Create a HTML h1 tag * * @param string $title Text to be in the h1 * @param integer $level Error level * * @return string */ private function addTitle($title, $level) { $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); return '<h1 style="background: '.$this->logLevels[$level].';color: #ffffff;padding: 5px;">'.$title.'</h1>'; } /** * Formats a log record. * * @param array $record A record to format * * @return mixed The formatted record */ public function format(array $record) { $output = $this->addTitle($record['level_name'], $record['level']); $output .= '<table cellspacing="1" width="100%">'; $output .= $this->addRow('Message', (string) $record['message']); $output .= $this->addRow('Time', $record['datetime']->format('Y-m-d\TH:i:s.uO')); $output .= $this->addRow('Channel', $record['channel']); if ($record['context']) { $output .= $this->addRow('Context', $this->convertToString($record['context'])); } if ($record['extra']) { $output .= $this->addRow('Extra', $this->convertToString($record['extra'])); } return $output.'</table>'; } /** * Formats a set of log records. * * @param array $records A set of records to format * * @return mixed The formatted set of records */ public function formatBatch(array $records) { $message = ''; foreach ($records as $record) { $message .= $this->format($record); } return $message; } protected function convertToString($data) { if (null === $data || is_scalar($data)) { return (string) $data; } $data = $this->normalize($data); if (version_compare(PHP_VERSION, '5.4.0', '>=')) { return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } return str_replace('\\/', '/', json_encode($data)); } }