diff options
-rw-r--r-- | apps/workflowengine/lib/Helper/LogContext.php | 2 | ||||
-rw-r--r-- | apps/workflowengine/lib/Service/Logger.php | 4 | ||||
-rw-r--r-- | lib/private/Log.php | 3 | ||||
-rw-r--r-- | lib/private/Log/LogDetails.php | 10 | ||||
-rw-r--r-- | lib/public/Log/IDataLogger.php | 6 |
5 files changed, 19 insertions, 6 deletions
diff --git a/apps/workflowengine/lib/Helper/LogContext.php b/apps/workflowengine/lib/Helper/LogContext.php index 786aa7cf85a..548e8722073 100644 --- a/apps/workflowengine/lib/Helper/LogContext.php +++ b/apps/workflowengine/lib/Helper/LogContext.php @@ -33,7 +33,7 @@ class LogContext { protected $details; public function setDescription(string $description): LogContext { - $this->details['description'] = $description; + $this->details['message'] = $description; return $this; } diff --git a/apps/workflowengine/lib/Service/Logger.php b/apps/workflowengine/lib/Service/Logger.php index 0bf09ed8a72..8b90e6fa159 100644 --- a/apps/workflowengine/lib/Service/Logger.php +++ b/apps/workflowengine/lib/Service/Logger.php @@ -162,8 +162,10 @@ class Logger { return; } + $details = $logContext->getDetails(); $this->flowLogger->logData( - $logContext->getDetails(), + $details['message'], + $details, ['app' => Application::APP_ID, 'level' => $context['level']] ); } diff --git a/lib/private/Log.php b/lib/private/Log.php index 8d51a673a46..d288e724179 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -340,7 +340,7 @@ class Log implements ILogger, IDataLogger { } } - public function logData(array $data, array $context = []): void { + public function logData(string $message, array $data, array $context = []): void { $app = $context['app'] ?? 'no app in context'; $level = $context['level'] ?? ILogger::ERROR; @@ -350,6 +350,7 @@ class Log implements ILogger, IDataLogger { try { if ($level >= $minLevel) { + $data['message'] = $message; if (!$this->logger instanceof IFileBased) { $data = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_UNESCAPED_SLASHES); } diff --git a/lib/private/Log/LogDetails.php b/lib/private/Log/LogDetails.php index 2eea17ad73d..b1dc6e4311b 100644 --- a/lib/private/Log/LogDetails.php +++ b/lib/private/Log/LogDetails.php @@ -80,6 +80,16 @@ abstract class LogDetails { 'userAgent', 'version' ); + + if(is_array($message) && !array_key_exists('Exception', $message)) { + // Exception messages should stay as they are, + // anything else modern is split to 'message' (string) and + // data (array) fields + $shortMessage = $message['message'] ?? '(no message provided)'; + $entry['data'] = $message; + $entry['message'] = $shortMessage; + } + return $entry; } diff --git a/lib/public/Log/IDataLogger.php b/lib/public/Log/IDataLogger.php index 895ba43f5ca..b5d3aa3075b 100644 --- a/lib/public/Log/IDataLogger.php +++ b/lib/public/Log/IDataLogger.php @@ -28,15 +28,15 @@ namespace OCP\Log; * Interface IDataLogger * * @package OCP\Log - * @since 18.0.0 + * @since 18.0.1 */ interface IDataLogger { /** * allows to log custom data, similar to how logException works * - * @since 18.0.0 + * @since 18.0.1 */ - public function logData(array $data, array $context = []): void; + public function logData(string $message, array $data, array $context = []): void; } |