File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,17 @@ public static function errorLog(
4343 error_log ("$ title: $ message " );
4444 return ;
4545 }
46- $ output = [
47- "message " => $ message ,
48- "REMOTE_USER " => $ _SERVER ["REMOTE_USER " ] ?? null ,
49- "REMOTE_ADDR " => $ _SERVER ["REMOTE_ADDR " ] ?? null ,
50- ];
46+ $ output = ["message " => $ message ];
47+ if (!is_null ($ data )) {
48+ try {
49+ \jsonEncode ($ data );
50+ $ output ["data " ] = $ data ;
51+ } catch (\JsonException $ e ) {
52+ $ output ["data " ] = "data could not be JSON encoded: " . $ e ->getMessage ();
53+ }
54+ }
55+ $ output ["REMOTE_USER " ] = $ _SERVER ["REMOTE_USER " ] ?? null ;
56+ $ output ["REMOTE_ADDR " ] = $ _SERVER ["REMOTE_ADDR " ] ?? null ;
5157 if (!is_null ($ errorid )) {
5258 $ output ["errorid " ] = $ errorid ;
5359 }
@@ -57,14 +63,6 @@ public static function errorLog(
5763 // newlines are bad for error log, but getTrace() is too verbose
5864 $ output ["trace " ] = explode ("\n" , (new \Exception ())->getTraceAsString ());
5965 }
60- if (!is_null ($ data )) {
61- try {
62- \jsonEncode ($ data );
63- $ output ["data " ] = $ data ;
64- } catch (\JsonException $ e ) {
65- $ output ["data " ] = "data could not be JSON encoded: " . $ e ->getMessage ();
66- }
67- }
6866 error_log ("$ title: " . \jsonEncode ($ output ));
6967 }
7068
You can’t perform that action at this time.
0 commit comments