diff --git a/ballerina/natives.bal b/ballerina/natives.bal index eadc5f9d..32b2c2e0 100644 --- a/ballerina/natives.bal +++ b/ballerina/natives.bal @@ -46,10 +46,16 @@ public type Valuer isolated function () returns anydata; # Key-Value pairs that needs to be displayed in the log. # # + msg - msg which cannot be a key +# + message - message which cannot be a key +# + time - time which cannot be a key +# + level - level which cannot be a key # + 'error - 'error which cannot be a key -# + stackTrace - error stack trace which cannot be a key +# + stackTrace - stackTrace which cannot be a key public type KeyValues record {| never msg?; + never message?; + never time?; + never level?; never 'error?; never stackTrace?; Value...; @@ -59,6 +65,12 @@ public type KeyValues record {| public type AnydataKeyValues record { # msg which cannot be a key never msg?; + # message which cannot be a key + never message?; + # time which cannot be a key + never time?; + # level which cannot be a key + never level?; # 'error which cannot be a key never 'error?; # stackTrace which cannot be a key diff --git a/changelog.md b/changelog.md index e07a31d4..353d91bb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Change Log -This file contains all the notable changes done to the Ballerina TCP package through the releases. +This file contains all the notable changes done to the Ballerina Log package through the releases. + +## [Unreleased] + +### Fixed + +- [Passing time as key in KeyValue pair replaces the logged time with the context value](https://github.com/ballerina-platform/ballerina-library/issues/7728) +- [Passing message as key in KeyValue pair replaces the logged message with the context value](https://github.com/ballerina-platform/ballerina-library/issues/8232) ## [2.14.0] - 2025-10-09 diff --git a/docs/spec/spec.md b/docs/spec/spec.md index a84a2ab1..2f61c559 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -100,6 +100,10 @@ time=2025-08-20T08:53:29.987+05:30 level=INFO module="" message="info log" curre time=2025-08-20T08:53:29.998+05:30 level=INFO module="" message="info log for id: 845315" ctx="{name: foo}" ``` +> **Note:** +> The key-value pairs provided for logging must not use the reserved keys `message`, `time`, or `level`. +> These keys are reserved for the log record fields and will result in a compile-time error if specified. + ## 3. Configure logging ### 3.1. Configure root log level