Skip to content

Commit

Permalink
Restore error handling capabilities for failing loggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Lannoy committed May 28, 2024
1 parent aacc579 commit fce57d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ All notable changes to **DecaLog** are documented in this *changelog*.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and **DecaLog** adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.1.0] - Not Yet Released
## [4.1.0] - 2024-05-28

### Added
- New listener for [WP Migrate](https://wordpress.org/plugins/wp-migrate-db/) Lite & Pro.

### Fixed
- [WP-CLI] PHP error in some cases when Elastic Cloud is a running logger.
- Some failing loggers may not be able to report their health state.

## [4.0.0] - 2024-05-13

Expand Down
12 changes: 6 additions & 6 deletions includes/features/class-dlogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function log( $level, $message, $code = 0, $phase = '', $signal = true )
if ( $debug && ! $this->is_debug_allowed() ) {
return false;
}
//try {
try {
$context = [
'class' => (string) $this->class,
'component' => (string) $this->name,
Expand All @@ -361,18 +361,18 @@ public function log( $level, $message, $code = 0, $phase = '', $signal = true )
}
$result = true;
// phpcs:ignore
//set_error_handler( function () use (&$result) {$result = false;} );
set_error_handler( function () use (&$result) {$result = false;} );
$this->logger->log( $level, $this->normalize_string( $message ), $this->normalize_array( $context ) );
// phpcs:ignore
//restore_error_handler();
/*} catch ( \Throwable $t ) {
restore_error_handler();
} catch ( \Throwable $t ) {
$result = false;
} finally {
if ( $signal && ! $result && ! $debug ) {
//$this->log( Logger::ALERT, 'error', 666, '', false );
}*/
}
return $result;
//}
}
}

/**
Expand Down

0 comments on commit fce57d6

Please sign in to comment.