redactor = new CredentialRedactor( $storage ); } /** * {@inheritdoc} */ public function debug( string $message, array $context = array() ): void { $this->log( 'DEBUG', $message, $context ); } /** * {@inheritdoc} */ public function error( string $message, array $context = array() ): void { $this->log( 'ERROR', $message, $context ); } /** * Formats one line and hands it to error_log(). * * @param string $level Level name. * @param string $message Message. * @param array $context Context. */ private function log( string $level, string $message, array $context ): void { $context = $this->redactor->redact_context( $context ); $line = '[' . gmdate( 'Y-m-d H:i:s' ) . '] ' . $level . ' ' . $message; if ( array() !== $context ) { $encoded = wp_json_encode( $context ); if ( false !== $encoded ) { $line .= ' ' . $encoded; } } error_log( $line ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } }