id() ); } /** * Store an event for this logger. * * @param array $event Event arguments. * @return int */ protected function log( array $event ) { try { if ( ! $this->enabled() ) { return 0; } $event['logger'] = $this->id(); return Recorder::log( $event ); } catch ( \Throwable $e ) { unset( $e ); return 0; } } /** * Listen to an action and ignore failures. * * @param string $hook Hook name. * @param string $method Method on this logger. * @param int $accepted Accepted arguments. * @param int $priority Priority. */ protected function listen( $hook, $method, $accepted = 1, $priority = 10 ) { add_action( $hook, function () use ( $method ) { if ( ! $this->enabled() ) { return; } try { call_user_func_array( array( $this, $method ), func_get_args() ); } catch ( \Throwable $e ) { unset( $e ); } }, $priority, $accepted ); } }