title: Best practice to let users inject a logger into nodejs modules
body: <p>I wrote this module for nodejs that can be used to dispatch events from anywhere via sockjs to the clients.</p>
  
  <p>Now I'd like to include some configurable logging mechanisms.</p>
  
  <p>At the moment, I'm adding winston as a dependency, require it as a logger in each class and use logger.error, logger.warn, ...</p>
  
  <pre><code>#logger.js
  var logger = require('winston');
  module.exports=logger;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#myClass
  var logger = require("./logger");
  logger.error("Something went wrong")
  </code></pre>
  
  <p>Now, how can I make the logger be replaceable by a custom logger or have the user configure the log level from OUTSIDE my module?</p>
  
  <p>They should of course not have to touch the module code to change the logger but be able to create the logger with loglevel and my module should use it, if available.</p>
  
  <p>Any receommendations on how to do that?</p>
  
  <p>Or is a hard dependency on "winston" ok and have the log level be configurable via npm-config?</p>