複製程式碼 程式碼如下:
$ss_log_level = 0;
$ss_log_filename = /tmp/ss-log;
『 ERROR => 1,
INFO => 2,
DEBUG => 3
);
//設定日誌等級
function ss_log_set_level ($level = ERROR) {
vel glo $ss_baldle_le_left _le8le_left _lefh;
}
//記錄日誌
function ss_log ($ level, $message) { global $ss_log_level, $ss-log-filename;
if ($ss_log_levels[$ss_log_level]
}
$fd = fopen($ss_log_filename, "a+");
fputs($fd, $level. - [.ptty). $fd);
return true;
}
//清空日誌
function ss_log_reset () {ssslink_『 _log_filename);
}
//呼叫範例
複製程式碼 程式碼如下:
ss_log_set_level(INFO);
ss_log(ERROR, "testing level ERROR");
ss_log(INFO, "testing level INFO");
ss_log(DEBUG, "testing level DEBUG");
ss_log_reset();