about summary refs log tree commit diff stats
path: root/classes/Debug.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-31 09:11:20 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-31 09:11:20 +0300
commitb58f0a8f2431040edf94edb21f9c884f20ba6049 (patch)
treeb70055bf14983a59242ae27cdba75f6d39d391a3 /classes/Debug.php
parentb76af33e9bfb57b46fb8d8292b614bf9ee2e3c2d (diff)
downloadthe-epube-b58f0a8f2431040edf94edb21f9c884f20ba6049.tar.gz
the-epube-b58f0a8f2431040edf94edb21f9c884f20ba6049.tar.xz
tabs to spaces
Diffstat (limited to 'classes/Debug.php')
-rw-r--r--classes/Debug.php132
1 files changed, 66 insertions, 66 deletions
diff --git a/classes/Debug.php b/classes/Debug.php
index 7e7cc29..0384c87 100644
--- a/classes/Debug.php
+++ b/classes/Debug.php
@@ -1,91 +1,91 @@
 <?php
 class Debug {
-	const LOG_DISABLED = -1;
-	const LOG_NORMAL = 0;
-	const LOG_VERBOSE = 1;
-	const LOG_EXTENDED = 2;
+    const LOG_DISABLED = -1;
+    const LOG_NORMAL = 0;
+    const LOG_VERBOSE = 1;
+    const LOG_EXTENDED = 2;
 
-	public static int $LOG_DISABLED = -1;
-	public static int $LOG_NORMAL = 0;
-	public static int $LOG_VERBOSE = 1;
-	public static int $LOG_EXTENDED = 2;
+    public static int $LOG_DISABLED = -1;
+    public static int $LOG_NORMAL = 0;
+    public static int $LOG_VERBOSE = 1;
+    public static int $LOG_EXTENDED = 2;
 
-	private static bool $enabled = false;
-	private static bool $quiet = false;
-	private static string $logfile = "";
-	private static int $loglevel = 0;
+    private static bool $enabled = false;
+    private static bool $quiet = false;
+    private static string $logfile = "";
+    private static int $loglevel = 0;
 
-	public static function set_logfile(string $logfile) : void {
-		self::$logfile = $logfile;
-	}
+    public static function set_logfile(string $logfile) : void {
+        self::$logfile = $logfile;
+    }
 
-	public static function enabled() : bool {
-		return self::$enabled;
-	}
+    public static function enabled() : bool {
+        return self::$enabled;
+    }
 
-	public static function set_enabled(bool $enable) : void {
-		self::$enabled = $enable;
-	}
+    public static function set_enabled(bool $enable) : void {
+        self::$enabled = $enable;
+    }
 
-	public static function set_quiet(bool $quiet) : void {
-		self::$quiet = $quiet;
-	}
+    public static function set_quiet(bool $quiet) : void {
+        self::$quiet = $quiet;
+    }
 
-	public static function set_loglevel(int $level) : void {
-		self::$loglevel = $level;
-	}
+    public static function set_loglevel(int $level) : void {
+        self::$loglevel = $level;
+    }
 
-	public static function get_loglevel() : int {
-		return self::$loglevel;
-	}
+    public static function get_loglevel() : int {
+        return self::$loglevel;
+    }
 
-	public static function log(string $message, int $level = 0) : void {
+    public static function log(string $message, int $level = 0) : void {
 
-		if (!self::$enabled || self::$loglevel < $level) return;
+        if (!self::$enabled || self::$loglevel < $level) return;
 
-		$ts = strftime("%H:%M:%S", time());
-		if (function_exists('posix_getpid')) {
-			$ts = "$ts/" . posix_getpid();
-		}
+        $ts = strftime("%H:%M:%S", time());
+        if (function_exists('posix_getpid')) {
+            $ts = "$ts/" . posix_getpid();
+        }
 
-		if (self::$logfile) {
-			$fp = fopen(self::$logfile, 'a+');
+        if (self::$logfile) {
+            $fp = fopen(self::$logfile, 'a+');
 
-			if ($fp) {
-				$locked = false;
+            if ($fp) {
+                $locked = false;
 
-				if (function_exists("flock")) {
-					$tries = 0;
+                if (function_exists("flock")) {
+                    $tries = 0;
 
-					// try to lock logfile for writing
-					while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) {
-						sleep(1);
-						++$tries;
-					}
+                    // try to lock logfile for writing
+                    while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) {
+                        sleep(1);
+                        ++$tries;
+                    }
 
-					if (!$locked) {
-						fclose($fp);
-						user_error("Unable to lock debugging log file: " . self::$logfile, E_USER_WARNING);
-						return;
-					}
-				}
+                    if (!$locked) {
+                        fclose($fp);
+                        user_error("Unable to lock debugging log file: " . self::$logfile, E_USER_WARNING);
+                        return;
+                    }
+                }
 
-				fputs($fp, "[$ts] $message\n");
+                fputs($fp, "[$ts] $message\n");
 
-				if (function_exists("flock")) {
-					flock($fp, LOCK_UN);
-				}
+                if (function_exists("flock")) {
+                    flock($fp, LOCK_UN);
+                }
 
-				fclose($fp);
+                fclose($fp);
 
-				if (self::$quiet)
-					return;
+                if (self::$quiet)
+                    return;
 
-			} else {
-				user_error("Unable to open debugging log file: " . self::$logfile, E_USER_WARNING);
-			}
-		}
+            } else {
+                user_error("Unable to open debugging log file: " . self::$logfile, E_USER_WARNING);
+            }
+        }
 
-		print "[$ts] $message\n";
-	}
+        print "[$ts] $message\n";
+    }
 }