Esempio n. 1
0
File: log.php Progetto: rsms/phpab
    }
    return false;
}
/**
 * Log a error message
 *
 * @param  mixed   arguments
 * @return bool    Success
 */
function log_error()
{
    static $level = 'ERROR';
    if (ABLog::$level > 0) {
        return log_msg(func_get_args(), $level, 1);
    }
    return false;
}
# INIT
if ($level === null) {
    $erep = error_reporting();
    ABLog::$level = ($erep & E_NOTICE ? 1 : 0) + ($erep & E_WARNING ? 1 : 0) + ($erep & E_ERROR ? 1 : 0);
}
if (!$dir) {
    $error_log = trim(ini_get('error_log'));
    if (!$error_log || $error_log == 'syslog') {
        ABLog::$dir = '/tmp/';
    } else {
        ABLog::$dir = dirname($error_log) . '/';
    }
}
define('AB_LOG', 1);
Esempio n. 2
0
File: boot.php Progetto: rsms/phpab
/**
 * Setup the logging system
 *
 * If you want to use the built-in logging system, you need to 
 * call this function at least once, in order to load the logging logic.
 * You might customize logging properties by providing custom
 * arguments. If you don't, default values are used. (see below)
 *
 * You can check if the logging has been loaded:
 * if(defined('AB_LOG'))
 *   print 'Logging is loaded';
 *
 * <br><b>Default values</b>
 *   - <samp>$dir = dirname(ini_get('error_log'))</samp> or /tmp if error_log is not set or points to syslog.
 *   - <samp>$defaultLogfile = 'web'</samp>
 *   - <samp>$level = (error_reporting() & E_NOTICE ? 1:0) + (error_reporting() & E_WARNING ? 1:0) + (error_reporting() & E_ERROR ? 1:0);</samp>
 * 
 * <br><b>Value of default Level</b>
 *   - Level is 3 (everything) if E_NOTICE, E_WARNING and E_ERROR is included in error reporting. (default)
 *   - Level is 2 (warnings and errors) if E_WARNING and E_ERROR is included in error reporting, but not E_NOTICE.
 *   - Level is 1 (only errors) if only E_ERROR is included in error reporting
 *   - Level is 0 (nothing) if neither E_NOTICE, E_WARNING or E_ERROR is included in error reporting.
 *
 * @param  string  NAME of log file. Correct: "my_log", Wrong: "my_log.log". ".log" 
 *                 is prepended to name and written to $dir. (null = use defaults)
 * @param  string  Absoulte path to a directory in which the web server can create 
 *                 files. (null = use defaults)
 * @param  int     Decides which messages acctually get written. 0 = none,
 *                 1 = only log_error, 2 = log_error and log_warn, 3+ = everything.
 *                 (null = use defaults)
 * @param  string
 * @param  bool
 * @return void
 * @see    log_info()
 * @see    log_warn()
 * @see    log_error()
 */
function log_setup($logfile = null, $dir = null, $level = 3, $msgPrefix = null, $includeTimestamp = true)
{
    require_once 'event.d/log.php';
    ABLog::$includeTimestamp = $includeTimestamp;
    if ($level !== null) {
        ABLog::$level = $level;
    }
    if ($dir) {
        ABLog::$dir = rtrim($dir, '/') . '/';
    }
    if ($logfile) {
        ABLog::$defaultFile = $logfile;
    }
    if ($msgPrefix) {
        ABLog::$msgPrefix = $msgPrefix;
    }
}