Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Logger | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
notify | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace NewfoldLabs\WP\Module\Data; |
4 | |
5 | /** |
6 | * Subscribes to the Event Manager and writes event data to a log file |
7 | */ |
8 | class Logger implements SubscriberInterface { |
9 | |
10 | /** |
11 | * Method for handling receiving event data |
12 | * |
13 | * @param array $events Array of Event objects representing data about the events that occurred |
14 | */ |
15 | public function notify( $events ) { |
16 | foreach ( $events as $event ) { |
17 | if ( ! $event ) { |
18 | return; |
19 | } |
20 | $log = wp_json_encode( $event, JSON_UNESCAPED_SLASHES ) . "\n"; |
21 | file_put_contents( dirname( __DIR__ ) . '/debug.log', $log, FILE_APPEND ); |
22 | } |
23 | } |
24 | } |