Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-deduce context when no context is given #3

Open
bbottema opened this issue Jun 7, 2015 · 5 comments
Open

Auto-deduce context when no context is given #3

bbottema opened this issue Jun 7, 2015 · 5 comments

Comments

@bbottema
Copy link
Member

bbottema commented Jun 7, 2015

We would like to take the context from the currently dependent service and its parent module.

I think that it will be hard to solve... I post it at stackoverflow.
get-module-and-controllerservicedirective-names-at-runtime

@francescobragagna
Copy link

I did'n get the solution: maybe I make a mistake, but if I not get a specific logger instance $log.getInstance('shiningInstance') , when I use simply $log.info('wellcome') inside MyController the result looks like:
10-8-2015 10:02:13::[global]> wellcome
Instead I was hoping to have something like
10-8-2015 10:02:13::[MyController]> wellcome

It's something to improve, or should I do something different?
In the linked stackOverflow response is written how define a controller, and inside it the $log is instanciated with controller name... but in this way should I do it for every controller?

@bbottema
Copy link
Member Author

$log.getInstance('shiningInstance') yields a logger instance you should use to do logging.

var logger = $log.getInstance('shiningInstance');
logger.info('welcome');

If you write $log.info('welcome') you are using angular-logger as a drop-in replacement for the old $log.log functions which use 'global' as context name.

@francescobragagna
Copy link

I would like to above, in any of my controller, writhe something like:
var logger= $log.getInstance('...');
and than refactor everywhere using logger. instead of $log.
logger.log('abc')

I was thinking there is a way to use $log.info('abc') and the logger take itself the controller name, to produce the logger-enhanced line as configured (controllerName, timestamp...)

@bbottema bbottema reopened this Aug 10, 2015
@bbottema
Copy link
Member Author

This issue is exactly about what you are looking for. Unfortunately, we have been unable to solve that puzzle yet.

@francescobragagna
Copy link

ah, ok, i was thinking the issue was closed because solved! 👍
Thanks for the info. Hope to finding a solution, if I found anything I will add here some comment! cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants