stormpath / stormpath-sdk-express

[Deprecated] Stormpath SDK for Node.js Express applications.
Apache License 2.0
23 stars 9 forks source link

Should not log to console (during init) #1

Open jpravetz opened 9 years ago

jpravetz commented 9 years ago

MiddlewareContext.js lines 43 and 51:

    console.log('Initializing Stormpath Client');
  console.log('Initializing Stormpath Application');

Some folks prefer to direct where logging goes. This is low priority.

robertjd commented 9 years ago

Hey @jpravetz, thanks for the input! How do you typically prefer to handle logging?

jpravetz commented 9 years ago

I don't know what the nodejs convention is. sequelizejs, which I used a few years ago, allowed you to specify the log function. I'd prefer a function callback too. If all your lib ever outputs is a string then it can be a simple callback with a string argument, otherwise I'd prefer a callback that takes a defined object (key values) as callback argument.

For added bonus, you would also pass the express request and/or response objects in the function. That way the logging library can attribute a log message to a request (eg. using a private request._reqId). This would not apply for app init, of course, since you don't have a request object in this situation. I use a module that I wrote 'epdoc-logger' that mixes in logging methods with the response object.