-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbootup.logger.php
More file actions
95 lines (85 loc) · 2.7 KB
/
Copy pathbootup.logger.php
File metadata and controls
95 lines (85 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php // vi: set fenc=utf-8 ts=4 sw=4 et:
/*
* Copyright (C) 2014 Nicolas Grekas - p@tchwork.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the (at your option):
* Apache License v2.0 (http://apache.org/licenses/LICENSE-2.0.txt), or
* GNU General Public License v2.0 (http://gnu.org/licenses/gpl-2.0.txt).
*/
if (! function_exists('dump'))
{
function dump($var)
{
Patchwork\Dumper::dump($var);
}
function set_dump_handler(\Closure $handler)
{
return Patchwork\Dumper::setHandler($handler);
}
}
if (function_exists('patchwork_require')) return;
isset($_SERVER['REQUEST_TIME_FLOAT']) or $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
/**
* This function encapsulates a require in its own isolated scope and forces
* the error reporting level to be always enabled for uncatchable fatal errors.
* By using it instead of a straight require, you are sure that any otherwise
* @-silenced fatal error will be reported to you.
*/
function patchwork_require($file)
{
Patchwork\PHP\InDepthErrorHandler::stackErrors();
try {$file = patchwork_do_require($file);}
catch (Exception $x) {}
Patchwork\PHP\InDepthErrorHandler::unstackErrors();
if (isset($x)) throw $x;
return $file;
}
function patchwork_do_require()
{
return require func_get_arg(0);
}
/**
* This function should be used instead of register_shutdown_function()
* so that shutdown functions are always called encapsulated into a try/catch
* that avoids any "Exception thrown without a stack frame" cryptic error
* and restores any custom exception handler.
*/
function patchwork_shutdown_register($callback)
{
if (! is_callable($callback)) return register_shutdown_function($callback);
$callback = func_get_args();
register_shutdown_function('patchwork_shutdown_call', $callback);
}
/**
* @internal Do not use this function directly, see above.
*/
function patchwork_shutdown_call($c)
{
try
{
call_user_func_array(array_shift($c), $c);
}
catch (Exception $e)
{
$c = set_exception_handler('var_dump');
restore_exception_handler();
if (null !== $c) call_user_func($c, $e);
else if (PHP_VERSION_ID >= 50306)
{
throw $e;
}
else
{
user_error(
"Uncaught exception '" . get_class($e) . "'"
. ('' !== $e->getMessage() ? " with message '{$e->getMessage()}'" : "" )
. " in {$e->getFile()}:{$e->getLine()}" . PHP_EOL
. "Stack trace:" . PHP_EOL
. "{$e->getTraceAsString()}" . PHP_EOL,
E_USER_WARNING
);
}
exit(255);
}
}