1 <?php // vim: set binary noeol et sw=4 sts=4:
3 require_once 'T/logconstants.php';
5 function logserr($str, $level = ERROR) {
7 logs("$str ($php_errormsg)", $level);
10 function logsdie($str, $level = CRITICAL) {
15 function logs($str, $level = INFO) {
16 global $LOGLEVEL, $LOGFP, $argv;
17 if ($str and ($LOGLEVEL & $level) == $level) {
18 fputs($LOGFP, sprintf("%s %s[%d] %-8s %s\n", strftime('%c'),
19 substr(basename($argv[0]), 3), getmypid(),
20 loglevel2str($level), $str));
24 function loglevel2str($level) {
25 if ($level == CRITICAL) {
28 if ($level == ERROR) {
31 if ($level == WARNING) {
37 if ($level == DEBUG) {