* @param bool $userPre if set to false then it will use <Br /> for new line , else inserts the code inside <pre></pre> * @return string html text */ public static function logToHtml($logText, $userPre = true) { $patterns = array(); $replacements = array(); foreach (self::$foregroundColors as $k => $f) { foreach (self::$backgroundColors as $k1 => $b) { $patterns[] = '/\\033\\[' . $f . 'm\\033\\[' . $b . 'm/'; $replacements[] = '<span style="color:' . self::$htmlColors[$k] . '; background:' . self::$htmlColors[$k1] . ';">'; } $patterns[] = '/\\033\\[' . $f . 'm/'; $replacements[] = '<span style="color:' . self::$htmlColors[$k] . '">'; } $patterns[] = '/\\033\\[0m/'; $replacements[] = '</span>'; $content = preg_replace($patterns, $replacements, $logText); if ($userPre) { return "<pre style='background:#000;color:#cfcfcf;font-size:11px;padding:5px;min-width:800px;overflow:auto;'>" . $content . '</pre>'; } else { return nl2br($content); } } public static function logToTextFile($logText) { return strip_tags(self::logToHtml($logText)); } } ALogger::init();