delinquent_files/debug.inc

Sat, 17 Feb 2024 15:36:09 +0100

author
Peter Gervai <grin@grin.hu>
date
Sat, 17 Feb 2024 15:36:09 +0100
changeset 6
8b4e205ffc94
parent 4
aa3e6379dc3d
permissions
-rw-r--r--

demon.php: ease some db pressure by not querying old entries (7 days).
- replaced some rejects workaround by exclusions
- some moar debug msgs

<?php

## simple debug framework
## (grin)
##
## $Id$

class Debug {
    private $debuglevel = 2;

    function __construct() {
        // wtf
    }

    function set_level($l) {
        $this->debuglevel = $l;
        $this->warn( "Set debug level to $this->debuglevel" );
    }

    function msg ($s) {
        $this->log( 0, $s );
    }

    function error ($s) {
        $this->log( 1, $s );
    }

    function warn ($s) {
        $this->log( 2, $s );
    }

    function info ($s) {
        $this->log( 5, $s );
    }

    function debug ($s) {
        $this->log( 8, $s );
    }

    function trace ($s) {
        $this->log( 9, $s );
    }
    
    function log ($level,$msg) {
        #$now = strftime("%Y-%m-%d %T");
        if( $level > $this->debuglevel ) {
            return;
        }

        $now = date('c');
        print( "$now [$level] $msg\n" );
    }
}

mercurial