PHP log implementation code

高洛峰
Release: 2023-03-01 11:56:01
Original
1348 people have browsed it

Copy code The 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 log level
  function ss_log_set_level ($level = ERROR) {
  global $ss_log_level;
  $ss_log_level = $level;
  }

//Record log

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;

 

//Call example
Copy the code The 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();

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!