Paramaterize TransactionProfiler log entries
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 22 Jun 2017 21:08:05 +0000 (14:08 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 28 Jun 2017 18:22:54 +0000 (18:22 +0000)
Change-Id: I4e468d818af48dba21cd2c567f4e6a58beb0924b

includes/libs/rdbms/TransactionProfiler.php

index 256f744..43b6f88 100644 (file)
@@ -329,20 +329,23 @@ class TransactionProfiler implements LoggerAwareInterface {
        /**
         * @param string $expect
         * @param string $query
-        * @param string|float|int $actual [optional]
+        * @param string|float|int $actual
         */
-       protected function reportExpectationViolated( $expect, $query, $actual = null ) {
+       protected function reportExpectationViolated( $expect, $query, $actual ) {
                if ( $this->silenced ) {
                        return;
                }
 
-               $n = $this->expect[$expect];
-               $by = $this->expectBy[$expect];
-               $actual = ( $actual !== null ) ? " (actual: $actual)" : "";
-
                $this->logger->info(
-                       "Expectation ($expect <= $n) by $by not met$actual:\n$query\n" .
-                       ( new RuntimeException() )->getTraceAsString()
+                       "Expectation ({measure} <= {max}) by {by} not met (actual: {actual}):\n{query}\n" .
+                       ( new RuntimeException() )->getTraceAsString(),
+                       [
+                               'measure' => $expect,
+                               'max' => $this->expect[$expect],
+                               'by' => $this->expectBy[$expect],
+                               'actual' => $actual,
+                               'query' => $query
+                       ]
                );
        }
 }