|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2016-2024 BigBlueButton Inc. and by respective authors (see below). |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software; you can redistribute it and/or modify it under the |
|
9
|
|
|
* terms of the GNU Lesser General Public License as published by the Free Software |
|
10
|
|
|
* Foundation; either version 3.0 of the License, or (at your option) any later |
|
11
|
|
|
* version. |
|
12
|
|
|
* |
|
13
|
|
|
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
|
14
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
15
|
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Lesser General Public License along |
|
18
|
|
|
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace BigBlueButton\Util; |
|
22
|
|
|
|
|
23
|
|
|
class FileDumper |
|
24
|
|
|
{ |
|
25
|
|
|
private const LINE = "------------------------------------------------------------------------------------------------------------------------\n"; |
|
26
|
|
|
private const FOLDER = './var/dump/'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param mixed $var |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function DUMP($var): void |
|
32
|
|
|
{ |
|
33
|
|
|
// Define contents |
|
34
|
|
|
$calledFrom = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
35
|
|
|
$headline1 = "{$calledFrom['file']} (Line: {$calledFrom['line']})"; // @phpstan-ignore-line |
|
36
|
|
|
$headline2 = "{$calledFrom['class']}::{$calledFrom['function']}()"; // @phpstan-ignore-line |
|
37
|
|
|
$dateTime = (new \DateTime())->format('Y_m_d_\T_H_i_s.u'); |
|
38
|
|
|
$filename = "dump_{$dateTime}.txt"; |
|
39
|
|
|
|
|
40
|
|
|
// Create folder if not exist |
|
41
|
|
|
if (!file_exists(self::FOLDER)) { |
|
42
|
|
|
mkdir(self::FOLDER, 0755, true); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// dump content in file |
|
46
|
|
|
ob_start(); |
|
47
|
|
|
echo self::LINE; |
|
48
|
|
|
echo "File: {$headline1}\n"; |
|
49
|
|
|
echo "Func: {$headline2}\n"; |
|
50
|
|
|
echo "Date: {$dateTime}\n"; |
|
51
|
|
|
echo self::LINE; |
|
52
|
|
|
var_dump($var); |
|
|
|
|
|
|
53
|
|
|
echo self::LINE; |
|
54
|
|
|
file_put_contents(self::FOLDER . $filename, ob_get_contents()); |
|
55
|
|
|
ob_end_clean(); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|