-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 5.0.0
-
Component/s: None
Description
The logging spec introduced nine different severity levels and each severity level should have its own logging method.
Acceptance Criteria
Each severity logger should:
- be marked as experimental
- only get called when the severity is less than or equal to itself for the corresponding component
- make use of a private helper to be called with the other eight logging methods in the future
The private logging helper should:
- generate a spec-compliant log that omits top-level null/nullish values and contains the timestamp, component, and severity keys at the top-level
- convert BSON documents to EJSON
- redact sensitive commands if needed
- write objects to object streams (based on writableObjectMode flag on destination stream)
- stringify the log before writing to the stream
Other:
- Update stream validation to check for a minimal interface instead of `instanceof Writable` and add a unit test to ensure compatible stream interfaces are accepted
- Replace UnifiedLogCollector class (introduced in
NODE-4685) in Unified Test runner with an object that implements the new minimal interface. - Update the Unified Spec Test Runner to be able to take logs in the format described in the Design Document and convert them to the format expected as laid out in the Unified Test Format Spec
Implementation Notes
Starting with implementing just one of these severity logging methods, in this case emergency, should ease the workload on reviewers. This allows us to get the core logic down quickly and once it gets approved the other severity logging methods will roughly follow the same format.
Internal data structures that are JS object should not be stringified nor truncated. BSON document stringification should be done via Node's utils.inspect().
Testing
In addition to testing the acceptance criteria listed above, test that the emergency logger:
- can write a log to an existing stream
- can write a log to a new stream
- won't log events of disabled components
- has to be done before
-
NODE-4814 Implement the remaining severity loggers
- Closed
-
NODE-4815 Stringify and truncate BSON docs passed into the logger
- Closed
- is duplicated by
-
NODE-4886 Implement the logging severity helpers
- Closed
- is related to
-
NODE-4849 Add Typescript support for mongodbLogPath in client options
- Closed