Skip to content
Snippets Groups Projects

Issue #3239006 by vierlex: Skip logging when using drush & JSON formatting

Open alex s requested to merge issue/log_stdout-3239006:8.x-1.x into 8.x-1.x
+ 12
0
@@ -70,6 +70,18 @@ class Stdout implements LoggerInterface {
if (empty($fmt)) {
$fmt = '[@severity] [@type] [@date] @message | uid: @uid | request-uri: @request_uri | refer: @referer | ip: @ip | link: @link';
}
elseif (json_validate($fmt)) {
if (PHP_SAPI === 'cli') {
$arg = \Drush\Drush::input()->getFirstArgument();
if( mb_strpos($arg, 'batch-process') !== FALSE){
# https://www.drupal.org/project/log_stdout/issues/3239006
# Switch back to default formattting
# to avoid error when using JSON Output
# while drush is running a Batch API process
$fmt = '@date|@timestamp|@severity|@type|@message|@uid|@request_uri|@referer|@ip|@link';
}
}
}
$entry = strtr($fmt, [
'@base_url' => $base_url,
Loading