@@ -270,9 +270,7 @@ public function set_context( array $context ) {
270
270
public static function log ( $ level , $ message , array $ context = array () ) {
271
271
try {
272
272
$ instance = self ::get_instance ();
273
- if ( $ instance ) {
274
- $ instance ->add_log_record ( $ level , $ message , $ context );
275
- }
273
+ $ instance ->add_log_record ( $ level , $ message , $ context );
276
274
} catch ( Throwable $ e ) {
277
275
if ( defined ( 'WP_DEBUG ' ) && WP_DEBUG ) {
278
276
error_log ( sprintf ( 'Feedzy_Rss_Feeds_Log error: %s ' , $ e ->getMessage () ) );
@@ -304,9 +302,9 @@ private function add_log_record( $level, $message, array $context = array() ) {
304
302
if ( ! isset ( $ merged_context ['function ' ] ) || ! isset ( $ merged_context ['line ' ] ) ) {
305
303
$ origin = $ this ->get_calling_origin ();
306
304
if ( ! isset ( $ merged_context ['function ' ] ) ) {
307
- $ merged_context ['function ' ] = is_array ( $ origin ) && isset ( $ origin ['function ' ] ) ? $ origin [ ' function ' ] : ( string ) $ origin ;
305
+ $ merged_context ['function ' ] = $ origin ['function ' ];
308
306
}
309
- if ( ! isset ( $ merged_context ['line ' ] ) && is_array ( $ origin ) && isset ( $ origin [ ' line ' ] ) ) {
307
+ if ( ! isset ( $ merged_context ['line ' ] ) ) {
310
308
$ merged_context ['line ' ] = $ origin ['line ' ];
311
309
}
312
310
}
@@ -364,8 +362,9 @@ public function append_to_themeisle_log( $log_entry ) {
364
362
$ formatted_message .= ' ' . wp_json_encode ( $ log_entry ['context ' ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
365
363
}
366
364
367
- $ function_signature = isset ( $ log_entry ['context ' ]['function ' ] ) ? $ log_entry ['context ' ]['function ' ] : 'unknown ' ;
368
- $ line_number = isset ( $ log_entry ['context ' ]['line ' ] ) ? $ log_entry ['context ' ]['line ' ] : null ;
365
+ $ context = isset ( $ log_entry ['context ' ] ) && is_array ( $ log_entry ['context ' ] ) ? $ log_entry ['context ' ] : array ();
366
+ $ function_signature = (string ) ( $ context ['function ' ] ?? 'unknown ' );
367
+ $ line_number = $ context ['line ' ] ?? null ;
369
368
370
369
do_action ( 'themeisle_log_event ' , FEEDZY_NAME , $ formatted_message , $ log_entry ['level ' ], $ function_signature , $ line_number );
371
370
}
@@ -385,17 +384,17 @@ private function get_calling_origin() {
385
384
if ( isset ( $ frame ['class ' ] ) && __CLASS__ === $ frame ['class ' ] ) {
386
385
continue ;
387
386
}
388
- if ( isset ( $ frame [ ' function ' ] ) ) {
389
- $ func = isset ( $ frame ['class ' ] )
390
- ? ( $ frame [ ' class ' ] . ( isset ( $ frame [ ' type ' ] ) ? $ frame [ ' type ' ] : ' :: ' ) . $ frame ['function ' ] . ' () ' )
391
- : ( $ frame ['function ' ] . ' () ' );
392
- $ line = isset ( $ frame [ ' line ' ] ) ? ( int ) $ frame [ ' line ' ] : null ;
393
-
394
- return array (
395
- ' function ' => $ func ,
396
- ' line ' => $ line ,
397
- );
398
- }
387
+
388
+ $ function_name = $ frame ['function ' ];
389
+ $ func = isset ( $ frame ['class ' ] )
390
+ ? ( $ frame ['class ' ] . ( isset ( $ frame [ ' type ' ] ) ? $ frame [ ' type ' ] : ' :: ' ) . $ function_name . ' () ' )
391
+ : ( $ function_name . ' () ' ) ;
392
+ $ line = isset ( $ frame [ ' line ' ] ) ? ( int ) $ frame [ ' line ' ] : null ;
393
+
394
+ return array (
395
+ ' function ' => $ func ,
396
+ ' line ' => $ line ,
397
+ );
399
398
}
400
399
return array (
401
400
'function ' => 'unknown ' ,
0 commit comments