Set context
See original GitHub issueIs it possible to set the context?
I am using the logger in a library which outputs:
2021-02-05T12:58:01.192Z DEBUG [my-module-my-module.js:20803] Hello world
But my-module is actually the client that uses the library not the module from the library and not the service I used the logger within.
I would like what is set what stands in the brackets. E.g. in Nest.js you would do it like this:
import { Logger } from 'ngx-logger';
@Injectable()
class MyService {
private logger = new Logger(MyService.name);
doSomething() {
this.logger.log('Doing something...');
}
}
Or alternatively it could be done like this:
import { Logger } from 'ngx-logger';
@Injectable()
class MyService {
constructor(private logger: Logger) {
logger.setContext(MyService.name);
}
doSomething() {
this.logger.log('Doing something...');
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
kubectl config set-context - Kubernetes
Sets a context entry in kubeconfig Specifying a name that already exists will merge new fields on top of existing values for those...
Read more >Kubectl Config Set-Context | Tutorial and Best Practices
Kubernetes comes with many tools to help you manage your clusters, including kubectl set-context. In this guide, you'll learn how to use this...
Read more >setcontext(2): get/set user context - Linux man page - Die.net
The function setcontext() restores the user context pointed at by ucp. A successful call does not return. The context should have been obtained...
Read more >kubectl Cheat Sheet | Kubernetes
Kubectl context and configuration. Set which Kubernetes cluster kubectl communicates with and modifies configuration information.
Read more >Set context | Microsoft Learn
Sets the context for shadow copy creation. If used without parameters, set context displays help at the command prompt.
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
Hi @MickL, I just published v5 that allows you to customise any behavior of the logger and that would be enough for your feature The doc is here : https://github.com/dbfannin/ngx-logger/blob/master/docs/customising.md In your case you would need to customise the metadata.service.ts
Still your feature request is probably something I’ll look into
Feature is available in 5.0.11 See doc here https://github.com/dbfannin/ngx-logger/blob/master/docs/features.md and full example here https://github.com/dbfannin/ngx-logger/tree/master/projects/demo/src/app/custom-instance