| 78 |
78 |
ryzom_log("$text: $dt ms");
|
| 79 |
79 |
}
|
| 80 |
80 |
|
|
81 |
// for PHP4 from http://us.php.net/manual/en/function.file-put-contents.php#68329
|
|
82 |
if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) {
|
|
83 |
define('FILE_APPEND', 1);
|
|
84 |
function file_put_contents($n, $d, $flag = false) {
|
|
85 |
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
|
|
86 |
$f = @fopen($n, $mode);
|
|
87 |
if ($f === false) {
|
|
88 |
return 0;
|
|
89 |
} else {
|
|
90 |
if (is_array($d)) $d = implode($d);
|
|
91 |
$bytes_written = fwrite($f, $d);
|
|
92 |
fclose($f);
|
|
93 |
return $bytes_written;
|
|
94 |
}
|
|
95 |
}
|
|
96 |
}
|
|
97 |
|
|
98 |
|
| 81 |
99 |
$ryzom_bench = 0;
|
| 82 |
|
$ryzom_fp = 0;
|
|
100 |
$ryzom_fp = false;
|
| 83 |
101 |
function ryzom_log_start($api_name) {
|
| 84 |
102 |
global $ryzom_bench, $ryzom_fp;
|
| 85 |
103 |
if(!file_exists('log')) mkdir('log');
|
| 86 |
|
$ryzom_fp = fopen("log/$api_name.log", 'a');
|
|
104 |
$ryzom_fp = "log/$api_name.log";
|
| 87 |
105 |
$ryzom_bench = ryzom_bench_start();
|
| 88 |
106 |
}
|
| 89 |
107 |
|
| 90 |
108 |
function ryzom_log_end() {
|
| 91 |
|
global $ryzom_bench, $ryzom_fp;
|
|
109 |
global $ryzom_bench;
|
| 92 |
110 |
ryzom_bench_end($ryzom_bench, 'total');
|
| 93 |
|
if($ryzom_fp) fclose($ryzom_fp);
|
| 94 |
111 |
}
|
| 95 |
112 |
|
| 96 |
113 |
function ryzom_log($str) {
|
| 97 |
114 |
global $ryzom_fp;
|
| 98 |
|
if($ryzom_fp) fwrite($ryzom_fp, date("Y-m-d H:i:s") .' '. $_SERVER['REMOTE_ADDR'] .' '. $_SERVER['REQUEST_URI'] ." $str\n");
|
|
115 |
if($ryzom_fp!==false) file_put_contents($ryzom_fp, date("Y-m-d H:i:s") .' '. $_SERVER['REMOTE_ADDR'] .' '. $_SERVER['REQUEST_URI'] ." $str\n", FILE_APPEND);
|
| 99 |
116 |
}
|
| 100 |
117 |
|
| 101 |
|
?>
|
|
118 |
?>
|