Copy codeThe Code is as follows:
$ Ss_log_level = 0;
$ Ss_log_filename =/tmp/ss-log;
$ Ss_log_levels = array (
NONE => 0,
ERROR => 1,
INFO => 2,
DEBUG => 3
);
// Set the Log Level
Function ss_log_set_level ($ level = ERROR ){
Global $ ss_log_level;
$ Ss_log_level = $ level;
}
// Record logs
Function ss_log ($ level, $ message) {global $ ss_log_level, $ ss-log-filename;
If ($ ss_log_levels [$ ss_log_level] <$ ss_log_levels [$ level]) {
// Do not display Log information
Return false;
}
$ Fd = fopen ($ ss_log_filename, "a + ");
Fputs ($ fd, $ level.-[. ss_times ***** p_pretty ().]-. $ message. "n ");
Fclose ($ fd );
Return true;
}
// Clear logs
Function ss_log_reset (){
Global $ ss_log_filename;
@ Unlink ($ ss_log_filename );
}
// Call example
Copy codeThe Code is as follows:
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 ();