feat: commonLoggerCreate with a context, a pino-style child logger - #159
Merged
Merged
Conversation
…ed context object Appends one tagged, frozen context object as the last argument of every log call. Wrapping a context logger merges (new keys win) instead of nesting; splitLogContext lets sinks lift it.
writeGCPStructuredLog spreads the context as top-level jsonPayload fields, meta last so severity and trace win. devLogger prints the context dimmed after the message.
…tyle entry per call Replaces commonLoggerContext/splitLogContext. A context as second argument makes the logger contextful: plain-object args are merged into the entry, the first Error becomes err, the rest is joined into msg. child(context) merges. The sink may be a CommonLogger such as console.
…uctured fields msg becomes message, an Error in err is serialized and its stack kept in message, meta is spread last. devLogger prints msg, err and then the remaining fields dimmed.
Replaces the two private isPlainObject copies in commonLogger and the backend-lib GCP sink.
There was a problem hiding this comment.
🟡 Changes recommended
The structured GCP path drops valid message fields and throws when logging circular structured data.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a pino-style contextual logger with child contexts and structured logging support for backend sinks.
Changes:
- Adds
PlainObjectdetection and typing. - Extends
commonLoggerCreatewith contexts, child loggers, and structured arguments. - Updates GCP/development sinks and adds coverage.
File summaries
| File | Description |
|---|---|
packages/js-lib/src/types.ts |
Adds PlainObject. |
packages/js-lib/src/log/commonLogger.ts |
Implements contextual and child loggers. |
packages/js-lib/src/log/commonLogger.test.ts |
Tests logger behavior. |
packages/js-lib/src/is.util.ts |
Adds _isPlainObject. |
packages/js-lib/src/is.util.test.ts |
Tests plain-object detection. |
packages/backend-lib/src/server/logMiddleware.ts |
Handles structured log entries. |
packages/backend-lib/src/server/logMiddleware.test.ts |
Tests backend logging behavior. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mrnagydavid
reviewed
Sep 22, 2026
…red entry is the body Claude-Session: https://claude.ai/code/session_0167KuoFQNJXsXrM6mc3R9ux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding a logger context object.
commonLoggerCreate(sink, context)makes a contextful logger: every call emits one object{ ...context, ...plainObjectArgs, err?, msg? }child(context)merges context, and the sink can be a CommonLogger such asconsole.The backend-lib changes makes the GCP sink write such an entry as structured jsonPayload fields (
msgbecomesmessage, an Error inerris serialized with its stack kept inmessage); separable if we want only the js-lib API here.