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

the Logger implementation doesn't expose the same api as console #2

Open
tsalzinger opened this issue Apr 14, 2016 · 0 comments
Open
Labels

Comments

@tsalzinger
Copy link
Contributor

When developing js applications and using console for logging one gets used to being able to provide an arbitrary number of arguments (with arbitrary types).

when using cat-log4angular this api changes sagnificantly.
first of all it only supports a single argument 'message'. when one tries to provide more then one argument it fails, except if the second argument is a function, as it changes the methods behaviour completely.

the second thing is that a string message is expected, as otherwise toString() is called implicitly (with the exception of Error instances, which aren't handled ideal either).

i would suggest changing both of these behaviours.
the actual log implementation should accept an arbitrary number of arguments and pass them along to the appender implementations.

for example the console appender could then look something like this

{
  report: function(level) {
    var args = Array.prototype.slice.call(arguments, 1);
    window.console[level].apply(window.console, args);
  }

which would correctly utilize the console handling of logging arbitrary types

the problem arises with the 'timing' functionality - this cannot be changed without breaking the current api, but i think it is worth it and just provide a cleaner api for it

something along the lines of:

log.debug.time(function() {
  /* code to be executed and 'timed' should be able to return a promise or utilize a callback */
});
@tsalzinger tsalzinger added the bug label Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant