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

write log level in logged message #8

Closed
bbottema opened this issue Jan 14, 2016 · 6 comments
Closed

write log level in logged message #8

bbottema opened this issue Jan 14, 2016 · 6 comments

Comments

@bbottema
Copy link
Member

Moved from pdorgambide/angular-logger#23

I would like to be able to see in logged messages which ones are ERROR or just WARN.

We could make prefixPattern to accept a third parameter corresponding to the log level used to log the message.

@bbottema
Copy link
Member Author

@pdesoyres, you mean to say you would like to add the text " DEBUG" or "ERROR" to the message prefix? Or do you want to see only a certain level of messages in the log excluding all other (above or below).

@pdesoyres
Copy link

@bbottema, yes I would like to see the log level ("DEBUG" for example) in the message prefix. This is because, when I read the output log, I want to see very easily the log level of the message.

@bbottema
Copy link
Member Author

@pdesoyres, what pattern would you like as a default? Currently it is '%s::[%s]> ' (timestamp, then context).

@pdesoyres
Copy link

@bbottema Something like '%s::[%s] [%s]> ' (timestamp; logLevel, context) may fit my need.

@bbottema
Copy link
Member Author

Alright, should be solved in v1.1.0.

By default, the loglevel is not shown, unless sprintf.js is missing in which case angular-logger falls back to basic prefixpattern that includes the logging level.

To add logging level to the prefix pattern, simply add the third placeholder:

logEnhancerProvider.prefixPattern = '%s::[%s] [%s]> ';

@pdesoyres
Copy link

@bbottema thank you for the fast implementation ! It works perfectly.

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

No branches or pull requests

2 participants