From b23cab80f73ac73a08c0f83db60d6b172623df75 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 26 Sep 2019 01:57:01 +0100 Subject: [PATCH] filebackend: Convert trigger_error to PSR log warning * Add 'filebackend' name to the context. * Convert message to a normalized form for better de-duplication in Logstash so that it is easier to see whether something is rare or common. Without this, each instance is unique and it might seem rare in a small sample of log messages. This does not fully solve T231107, because we'd really want to know at least the file name the issue is about, but it seems the FileBackendStore does not have access to that right now, that's for a future commit. (It also can't be logged from the caller right now because this method does not expose the result of the operation in question). Bug: T231107 Change-Id: Iaf18d7d5c11334c84077667aa147d99fadb76a30 --- includes/libs/filebackend/FileBackendStore.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/libs/filebackend/FileBackendStore.php b/includes/libs/filebackend/FileBackendStore.php index d7d428ebff..ffb8793ccf 100644 --- a/includes/libs/filebackend/FileBackendStore.php +++ b/includes/libs/filebackend/FileBackendStore.php @@ -1440,7 +1440,10 @@ abstract class FileBackendStore extends FileBackend { $name = strtolower( $name ); $maxHVLen = in_array( $name, $longs ) ? INF : 255; if ( strlen( $name ) > 255 || strlen( $value ) > $maxHVLen ) { - trigger_error( "Header '$name: $value' is too long." ); + $this->logger->error( "Header '{header}' is too long.", [ + 'filebackend' => $this->name, + 'header' => "$name: $value", + ] ); } else { $newHeaders[$name] = strlen( $value ) ? $value : ''; // null/false => "" } @@ -1789,7 +1792,9 @@ abstract class FileBackendStore extends FileBackend { */ final protected function deleteContainerCache( $container ) { if ( !$this->memCache->delete( $this->containerCacheKey( $container ), 300 ) ) { - trigger_error( "Unable to delete stat cache for container $container." ); + $this->logger->warning( "Unable to delete stat cache for container {container}.", + [ 'filebackend' => $this->name, 'container' => $container ] + ); } } @@ -1887,7 +1892,9 @@ abstract class FileBackendStore extends FileBackend { return; // invalid storage path } if ( !$this->memCache->delete( $this->fileCacheKey( $path ), 300 ) ) { - trigger_error( "Unable to delete stat cache for file $path." ); + $this->logger->warning( "Unable to delete stat cache for file {path}.", + [ 'filebackend' => $this->name, 'path' => $path ] + ); } } -- 2.20.1