/usr/share/zoph/www/php/log.inc.php is in zoph 0.9.4-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | <?php
/**
* Class that takes care of logging
*
* This file is part of Zoph.
*
* Zoph is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Zoph is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Zoph; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @author Jeroen Roos
* @package Zoph
*/
/**
* This class takes care of logging and debug
*
* @author Jeroen Roos
* @package Zoph
*/
class log {
public static $stopOnFatal=true;
public static $sev = array(
60 => "Debug",
50 => "Debug",
40 => "Notification",
30 => "Warning",
20 => "Error",
10 => "Fatal Error",
5 => "Message",
1 => "To File",
0 => "None");
const MOREDEBUG = 60;
const DEBUG = 50;
const NOTIFY = 40;
const WARN = 30;
const ERROR = 20;
const FATAL = 10;
const MSG = 5;
const NONE = 0;
const TOFILE = 1;
const VARS = 1;
const LANG = 2;
const LOGIN = 4;
const REDIRECT = 8;
const IMPORT = 16;
const GEOTAG = 32;
const CONFIG = 64;
const DB = 128;
const SQL = 256;
const XML = 512;
const CONF = 1024;
/* 2048, is free */
const IMG = 4096;
/* 8192, 16384 are free */
const GENERAL = 32768;
const ALL=65535;
/**
* Log a message
* for now, only to the screen, but I may add file and database later;
* @param string Message to be displayed
* @param bigint Severity of the message, use the constants defined
* @param bigint Subject of the message.
* @param bool echo the message or return the contents
*/
public static function msg($msg,
$severity = self::NOTIFY, $subj = self::GENERAL, $print = true) {
/**
* There are 3 settings in config.ing.php that are important;
* LOG_SEVERITY: Show log messages with a severity higher than this
* LOG_SUBJECT: Only show messages about this subject
* LOG_ALWAYS: Always show messages with a severity higher than this
* no matter what the subject is.
*/
if (((LOG_SEVERITY >= $severity) && (LOG_SUBJECT & $subj)) ||
(LOG_ALWAYS >= $severity)) {
$dbt = debug_backtrace();
$file = basename($dbt[0]["file"]);
$line = $dbt[0]["line"];
$msg="<b>" . static::$sev[$severity] . "</b>: " . $msg . " <tt>" . $file . "</tt>: " . $line . ".<br>\n";
if ($print) {
if (!defined("CLI")) {
echo $msg;
} else {
$html=array("<b>", "</b>", "<strong>", "<strong>", "<br>", "<tt>", "</tt>");
$cli=array("\033[1m", "\033[0m", "\033[1m", "\033[0m", "\n", "", "");
echo str_replace($html, $cli, $msg);
}
} else {
return $msg;
}
}
if ($severity == static::FATAL && static::$stopOnFatal) {
die("fatal error");
}
}
}
?>
|