# searchpro/4.1.13/inc/class-berqlogs.php

BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS &amp; JavaScript, version 4.1.13. 74 lines.

- Page: https://pluginprobe.com/plugins/searchpro/4.1.13/code/inc/class-berqlogs.php
- Raw: https://pluginprobe.com/plugins/searchpro/4.1.13/raw/inc/class-berqlogs.php
- Modified: 2025-04-19T13:22:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/searchpro/4.1.13/code/inc/class-berqlogs.php#L10-L20`.

```php
<?php
// class berqLogs {
//     private $logFile;

//     public function __construct() {
//         $this->logFile = optifer_cache . 'berqwp.log';
//     }

//     public function log($message, $status = 'INFO') {
//         $timestamp = date('Y-m-d H:i:s');
//         $logEntry = "[$timestamp][$status]: $message" . PHP_EOL;
//         file_put_contents($this->logFile, $logEntry, FILE_APPEND);
//     }

//     public function info($message) {
//         $this->log($message, 'INFO');
//     }

//     public function warning($message) {
//         $this->log($message, 'WARNING');
//     }

//     public function error($message) {
//         $this->log($message, 'ERROR');
//     }
// }

// global $berq_log;
// $berq_log = new berqLogs();

class berqLogs {
    private $logFile;
    private $logDir;
    private $maxSize = 1048576 * 20;

    public function __construct() {
        $this->logDir = rtrim(optifer_cache, '/') . '/logs/';
        if (!file_exists($this->logDir)) {
            mkdir($this->logDir, 0755, true);
        }

        $this->logFile = $this->logDir . 'berqwp.log';
    }

    private function checkLogSize() {
        if (file_exists($this->logFile) && filesize($this->logFile) >= $this->maxSize) {
            $backup = $this->logDir . 'berqwp_' . date('Ymd_His') . '.log';
            rename($this->logFile, $backup);
        }
    }

    public function log($message, $status = 'INFO') {
        $this->checkLogSize();
        $timestamp = date('Y-m-d H:i:s');
        $logEntry = "[$timestamp][$status]: $message" . PHP_EOL;
        file_put_contents($this->logFile, $logEntry, FILE_APPEND);
    }

    public function info($message) {
        $this->log($message, 'INFO');
    }

    public function warning($message) {
        $this->log($message, 'WARNING');
    }

    public function error($message) {
        $this->log($message, 'ERROR');
    }
}

global $berq_log;
$berq_log = new berqLogs();

```
