Feature request: Context hierarchy
See original GitHub issueContext To start with, some context for this feature request. I would like to:
- Incrementally add contextual information to my logging, as my code progresses.
- Remove contextual information when I leave the context for which that data is relevant.
- Have
console.log
statements include the context
Provided solution The library doesn’t make it impossible to do this, but it lacks a bit of convenience:
- is currently possible by adding data either to the global logger or a local logger.
- is currently possible only by overwriting the entire context. This method is inconvenient for removing just the bits that are no longer relevant, and is further constrained because I cannot query the current context. As such, the only real way to do this currently is set up our own context tracking mechanism next to the one datadog provides.
- although we can fork local loggers from global loggers for a single extra layer of context, the
console.logs
made from this context wouldn’t include that additional context.
Proposed solution Include the following API and implementation:
pushContext([key1: value1, ..., keyN: valueN}])
to push a bit of context into a global context arraypopContext()
to remove one layer of context from the global context stack.
For each log statement issued, assemble a context by merging context layers, overwriting older context values with newer ones on key conflicts.
For now I am doing the above myself with some React components in my app, but I think this would be a great addition for anybody using this logging package.
Thanks in advance for your consideration!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Organizing your feature ideas - Productboard Support
Learn best practices around setting up your feature hierarchy in our on-demand webinar. A member of team Productboard will explain key ...
Read more >Feature request: Sub-table/hierarchical view - Suggestion Box
So I can use column relationships (parent/child) to manage an existing table of data as an indented (and collapsable) hierarchy. I've seen some ......
Read more >Request Features in ASP.NET Core | Microsoft Learn
IHttpRequestFeature: Defines the structure of an HTTP request, including the protocol, path, query string, headers, and body. This feature is ...
Read more >Hybrid hierarchical perspective (feature request) - OmniFocus
Currently there are two main perspective types in Omnifocus. One that shows the Project Hierarchy an done that does not.
Read more >Show hierarchy for filtered cards | Voters - Favro - Canny
Filtering of any type in backlogs hides hierarchies, removing important context. There should be a Show Hierarchy switch on the filter menu that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The ability to remove global context key has been added to log in v1.15.0 and to rum in v1.20.0.
This would be useful for projects that have used services like TrackJS in the past. TrackJS allows you to add metadata that can be removed when not needed anymore (https://docs.trackjs.com/browser-agent/sdk-reference/agent-methods/#removemetadata). This can be helpful when debugging errors that can be hard to reproduce or to have more context when a known error is triggered. eg.