delinquent_files/debug.inc

changeset 0
3b714bbb1347
child 2
cd58c0bc21d6
equal deleted inserted replaced
-1:000000000000 0:3b714bbb1347
1 <?php
2
3 ## simple debug framework
4 ## (grin)
5 ##
6 ## $Id$
7
8 class Debug {
9 private $debuglevel = 2;
10
11 function __construct() {
12 // wtf
13 }
14
15 function set_level($l) {
16 $this->debuglevel = $l;
17 $this->warn( "Set debug level to $this->debuglevel" );
18 }
19
20 function msg ($s) {
21 $this->log( 0, $s );
22 }
23
24 function error ($s) {
25 $this->log( 1, $s );
26 }
27
28 function warn ($s) {
29 $this->log( 2, $s );
30 }
31
32 function info ($s) {
33 $this->log( 5, $s );
34 }
35
36 function debug ($s) {
37 $this->log( 8, $s );
38 }
39
40 function trace ($s) {
41 $this->log( 9, $s );
42 }
43
44 function log ($level,$msg) {
45 #$now = strftime("%Y-%m-%d %T");
46 if( $level > $this->debuglevel ) {
47 return;
48 }
49
50 $now = date('c');
51 print( "$now [$level] $msg\n" );
52 }
53 }
54

mercurial