75 $this->_id = md5(microtime());
76 $this->_name = str_replace(
' ',
'_',
$name);
77 $this->_ident = $ident;
80 if (isset($conf[
'title'])) {
81 $this->_title = $conf[
'title'];
83 if (isset($conf[
'styles']) && is_array($conf[
'styles'])) {
84 $this->_styles = $conf[
'styles'];
86 if (isset($conf[
'colors']) && is_array($conf[
'colors'])) {
87 foreach ($conf[
'colors'] as $level => $color) {
88 $this->_styles[$level] .=
"color: $color;";
92 register_shutdown_function(array(&$this,
'_Log_win'));
100 if ($this->_opened || (count($this->_buffer) > 0)) {
115 if (!$this->_opened) {
119 if (!empty($this->_ident)) {
120 $identHeader =
"$win.document.writeln('<th>Ident</th>')";
126 <script language=
"JavaScript">
127 $win = window.open(
'',
'{$this->_name}',
'toolbar=no,scrollbars,width=600,height=400');
128 $win.document.writeln(
'<html>');
129 $win.document.writeln(
'<head>');
130 $win.document.writeln(
'<title>{$this->_title}</title>');
131 $win.document.writeln(
'<style type="text/css">');
132 $win.document.writeln(
'body { font-family: monospace; font-size: 8pt; }');
133 $win.document.writeln(
'td,th { font-size: 8pt; }');
134 $win.document.writeln(
'td,th { border-bottom: #999999 solid 1px; }');
135 $win.document.writeln(
'td,th { border-right: #999999 solid 1px; }');
136 $win.document.writeln(
'tr { text-align: left; vertical-align: top; }');
137 $win.document.writeln(
'td.l0 { $styles[0] }');
138 $win.document.writeln(
'td.l1 { $styles[1] }');
139 $win.document.writeln(
'td.l2 { $styles[2] }');
140 $win.document.writeln(
'td.l3 { $styles[3] }');
141 $win.document.writeln(
'td.l4 { $styles[4] }');
142 $win.document.writeln(
'td.l5 { $styles[5] }');
143 $win.document.writeln(
'td.l6 { $styles[6] }');
144 $win.document.writeln(
'td.l7 { $styles[7] }');
145 $win.document.writeln(
'</style>');
146 $win.document.writeln(
'<script type="text/javascript">');
147 $win.document.writeln(
'function scroll() {');
148 $win.document.writeln(
' body = document.getElementById("{$this->_name}");');
149 $win.document.writeln(
' body.scrollTop = body.scrollHeight;');
150 $win.document.writeln(
'}');
151 $win.document.writeln(
'<\/script>');
152 $win.document.writeln(
'</head>');
153 $win.document.writeln(
'<body id="{$this->_name}" onclick="scroll()">');
154 $win.document.writeln(
'<table border="0" cellpadding="2" cellspacing="0">');
155 $win.document.writeln(
'<tr><th>Time</th>');
157 $win.document.writeln(
'<th>Priority</th><th width="100%">Message</th></tr>');
160 $this->_opened =
true;
179 if (!$this->_opened && (count($this->_buffer) > 0)) {
183 if ($this->_opened) {
187 $this->_opened =
false;
190 return ($this->_opened ===
false);
201 foreach ($this->_buffer as $line) {
202 echo
"<script language='JavaScript'>\n";
203 echo
"$win.document.writeln('" . addslashes($line) .
"');\n";
204 echo
"self.focus();\n";
209 $this->_buffer = array();
222 $this->_buffer[] = $line;
225 if (!headers_sent()) {
230 if (!$this->_opened && !$this->
open()) {
250 function log($message, $priority = null)
253 if ($priority === null) {
264 $message = preg_replace(
'/\r\n|\n|\r/',
'<br />', $message);
266 list($usec, $sec) = explode(
' ', microtime());
270 $line .= sprintf(
'<td>%s.%s</td>',
271 strftime(
'%H:%M:%S', $sec), substr($usec, 2, 2));
272 if (!empty($this->_ident)) {
273 $line .=
'<td>' . $this->_ident .
'</td>';
276 $line .= sprintf(
'<td class="l%d">%s</td>', $priority, $message);
281 $this->
_announce(array(
'priority' => $priority,
'message' => $message));