PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / trunk
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript vtrunk
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
← All changes | inc/class-berqlogs.php +46 -2 1.9.3trunk View file →
@@ -1,13 +1,57 @@
1 1 <?php
2 +// class berqLogs {
3 +// private $logFile;
4 +
5 +// public function __construct() {
6 +// $this->logFile = optifer_cache . 'berqwp.log';
7 +// }
8 +
9 +// public function log($message, $status = 'INFO') {
10 +// $timestamp = date('Y-m-d H:i:s');
11 +// $logEntry = "[$timestamp][$status]: $message" . PHP_EOL;
12 +// file_put_contents($this->logFile, $logEntry, FILE_APPEND);
13 +// }
14 +
15 +// public function info($message) {
16 +// $this->log($message, 'INFO');
17 +// }
18 +
19 +// public function warning($message) {
20 +// $this->log($message, 'WARNING');
21 +// }
22 +
23 +// public function error($message) {
24 +// $this->log($message, 'ERROR');
25 +// }
26 +// }
27 +
28 +// global $berq_log;
29 +// $berq_log = new berqLogs();
30 +
2 31 class berqLogs {
3 32 private $logFile;
33 + private $logDir;
34 + private $maxSize = 1048576 * 20;
4 35
5 36 public function __construct() {
6 - $this->logFile = optifer_cache . 'berqwp.log';
37 + $this->logDir = rtrim(optifer_cache, '/') . '/logs/';
38 + if (!file_exists($this->logDir)) {
39 + mkdir($this->logDir, 0755, true);
40 + }
41 +
42 + $this->logFile = $this->logDir . 'berqwp.log';
7 43 }
8 44
45 + private function checkLogSize() {
46 + if (file_exists($this->logFile) && filesize($this->logFile) >= $this->maxSize) {
47 + $backup = $this->logDir . 'berqwp_' . date('Ymd_His') . '.log';
48 + rename($this->logFile, $backup);
49 + }
50 + }
51 +
9 52 public function log($message, $status = 'INFO') {
53 + $this->checkLogSize();
10 54 $timestamp = date('Y-m-d H:i:s');
11 55 $logEntry = "[$timestamp][$status]: $message" . PHP_EOL;
12 56 file_put_contents($this->logFile, $logEntry, FILE_APPEND);
13 57 }
@@ -25,5 +69,5 @@
25 69 }
26 70 }
27 71
28 72 global $berq_log;
29 -$berq_log = new berqLogs();
73 +$berq_log = new berqLogs();