PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.83
WindPress – Tailwind CSS integration for WordPress v3.2.83
3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 All 142 releases
windpress / src / Utils / Debug.php

Debug.php in WindPress – Tailwind CSS integration for WordPress 3.2.83, at src/Utils/Debug.php

61 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the WindPress package.
5 *
6 * (c) Joshua Gugun Siagian <suabahasa@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 declare (strict_types=1);
12 namespace WindPress\WindPress\Utils;
13
14 use WindPressDeps\Symfony\Component\Stopwatch\Stopwatch;
15 use Throwable;
16 /**
17 * Debug tools for the plugin.
18 *
19 * @since 3.0.0
20 */
21 class Debug
22 {
23 /**
24 * The stopwatch instance.
25 */
26 private static Stopwatch $stopwatch;
27 /**
28 * Get the stopwatch instance.
29 */
30 public static function stopwatch(): Stopwatch
31 {
32 if (!isset(self::$stopwatch)) {
33 self::$stopwatch = new Stopwatch(\true);
34 }
35 return self::$stopwatch;
36 }
37 public static function shutdown()
38 {
39 if (isset(self::$stopwatch)) {
40 // self::shutdown_stopwatch();
41 }
42 }
43 public static function shutdown_stopwatch()
44 {
45 $stopwatchEvent = self::stopwatch()->getSectionEvents('__root__');
46 if ($stopwatchEvent === []) {
47 return;
48 }
49 $log = '=== ' . gmdate('Y-m-d H:i:s', time()) . ' ===' . \PHP_EOL;
50 foreach ($stopwatchEvent as $ev) {
51 $log .= (string) $ev . \PHP_EOL;
52 }
53 $log .= \PHP_EOL;
54 $path = wp_upload_dir()['basedir'] . '/windpress/debug/stopwatch.log';
55 try {
56 \WindPress\WindPress\Utils\Common::save_file($log, $path, \FILE_APPEND);
57 } catch (Throwable $throwable) {
58 }
59 }
60 }
61