0, 'info' => 1, 'warning' => 2, 'error' => 3, ]; public static function debug(string $context, string $message): void { self::log('debug', $context, $message); } public static function info(string $context, string $message): void { self::log('info', $context, $message); } public static function warning(string $context, string $message): void { self::log('warning', $context, $message); } public static function error(string $context, string $message): void { self::log('error', $context, $message); } private static function log(string $level, string $context, string $message): void { $configuredLevel = Config::get('log_level', 'info'); $configuredLevel = self::LEVELS[$configuredLevel] ?? self::LEVELS['info']; $currentLevel = self::LEVELS[$level] ?? self::LEVELS['info']; if ($currentLevel < $configuredLevel) { return; } $date = current_time('Y-m-d H:i:s'); $fileName = SENTINELO_LOG_DIR . 'sentinelo-' . current_time('Y-m-d') . '.log'; $line = sprintf("[%s] [%s] [%s] %s\n", $date, strtoupper($level), $context, $message); if (!is_dir(SENTINELO_LOG_DIR)) { sentinelo_protect_storage(); wp_mkdir_p(SENTINELO_LOG_DIR); } $handle = fopen($fileName, 'ab'); if ($handle === false) { return; } if (flock($handle, LOCK_EX)) { fwrite($handle, $line); fflush($handle); flock($handle, LOCK_UN); } fclose($handle); } }