PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
← All changes | includes/Logger.php +19 -3 1.10.01.10.18 View file →
@@ -117,9 +117,20 @@
117 117 if ( '' !== $context_string ) {
118 118 $full_message .= ' | Context: ' . $context_string;
119 119 }
120 120
121 - self::write_log( $full_message );
121 + $written = self::write_log( $full_message );
122 +
123 + // Forward after dedup so "repeated N times" remains one event, and only
124 + // when the write itself was allowed: `woocommerce_pos_logging` is how a
125 + // site says "do not record this", so it must gate the remote copy too.
126 + if ( $written && ( 'error' === self::$log_level || 'critical' === self::$log_level ) ) {
127 + try {
128 + \WCPOS\WooCommercePOS\Services\Error_Reporter::report_log_error( self::$log_level, $message, $context_string );
129 + } catch ( \Throwable $t ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
130 + // Reporting must never break logging.
131 + }
132 + }
122 133 }
123 134
124 135 /**
125 136 * Flush any pending repeat count to the log.
@@ -185,12 +196,15 @@
185 196 * Registers a shutdown hook on first write to flush any remaining
186 197 * repeat count at end of request.
187 198 *
188 199 * @param string $message The formatted message to write.
200 + *
201 + * @return bool Whether the message was written, so callers can mirror the
202 + * `woocommerce_pos_logging` decision instead of re-applying it.
189 203 */
190 - private static function write_log( string $message ): void {
204 + private static function write_log( string $message ): bool {
191 205 if ( ! apply_filters( 'woocommerce_pos_logging', true, $message ) ) {
192 - return;
206 + return false;
193 207 }
194 208
195 209 if ( ! isset( self::$logger ) ) {
196 210 self::$logger = wc_get_logger();
@@ -206,6 +220,8 @@
206 220 Logger::flush_repeat_count();
207 221 }
208 222 );
209 223 }
224 +
225 + return true;
210 226 }
211 227 }