delinquent_files/debug.inc

Mon, 23 Jan 2023 21:37:02 +0100

author
Peter Gervai <grin@grin.hu>
date
Mon, 23 Jan 2023 21:37:02 +0100
changeset 0
3b714bbb1347
child 2
cd58c0bc21d6
permissions
-rw-r--r--

Add files without passwords and other unwanted fluff.

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

mercurial