delinquent_files/debug.inc

Mon, 23 Jan 2023 21:39:43 +0100

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

BotSecrets.pm-sample: add some comments to help to see which variable is what

<?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