7 |
rodolico |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
require_once 'LogFile.class.php';
|
|
|
4 |
|
|
|
5 |
class DebugFile extends LogFile {
|
|
|
6 |
|
|
|
7 |
public $logLevel = 5; // logging level
|
|
|
8 |
|
|
|
9 |
public function __constructor( $filename = null, $logLevel = null, $maxSize = null ) {
|
|
|
10 |
// session variables can create defaults
|
|
|
11 |
if ( isset( $_SESSION['DEBUG']['level'] ) && $logLevel === null ) {
|
|
|
12 |
$this->logLevel = $_SESSION['DEBUG']['level'];
|
|
|
13 |
} else {
|
|
|
14 |
$this->logLevel = $logLevel;
|
|
|
15 |
}
|
|
|
16 |
if ( isset( $_SESSION['DEBUG']['File Name'] )
|
|
|
17 |
&& ( $filename === null || strlen( $filename ) == 0 )
|
|
|
18 |
) {
|
|
|
19 |
$filename = $_SESSION['DEBUG']['File Name'];
|
|
|
20 |
}
|
|
|
21 |
parent::_constructor( $filename, null, $maxSize, null );
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public function writeLog( $logLevel, $message, $file = null, $class = null, $function = null, $line = null ) {
|
|
|
25 |
if ( $logLevel <= $this->logLevel ) {
|
|
|
26 |
$extra = array();
|
|
|
27 |
if ( isset( $file ) ) $extra[] = "File: $file";
|
|
|
28 |
if ( isset( $class ) ) $extra[] = "Class: $class";
|
|
|
29 |
if ( isset( $function ) ) $extra[] = "Function: $function";
|
|
|
30 |
if ( isset( $line ) ) $extra[] = "Line: $line";
|
8 |
rodolico |
31 |
$message = implode( ', ', $extra ) . $message;
|
7 |
rodolico |
32 |
return parent::writeLog( $message );
|
|
|
33 |
} else {
|
|
|
34 |
return true;
|
|
|
35 |
}
|
|
|
36 |
} // writeLog
|
|
|
37 |
} // class logging
|
|
|
38 |
|
|
|
39 |
?>
|
|
|
40 |
|