title: Is there a clean way to add a logger to the global namespace in a Node server?
body: <p>In the top-level of each route handler in my (very small) server (I'm using the library <code>micro</code>, which seems to mimic a lot of <code>Express</code>), I instantiate a <code>logger</code> that sends logs to <code>elasticsearch</code>. By passing a <code>name</code> to the logger constructor, the logger appends that name to all logs it produces. </p>
  
  <p>The hierarchy looks something like this:</p>
  
  <pre><code>router
    -routeA:
      global._logger = _logger(name: 'routeA')
    -routeB:
      global._logger = _logger(name: 'routeB') 
  </code></pre>
  
  <p>My question is: if the server is handling multiple concurrent requests, will the <code>global._logger</code> be overwritten with each new route handler instantiation? </p>
  
  <p>If so, is there a cleaner way to attach my <code>logger</code> to the global scope, vice passing it to every function I call?</p>
  
  <p>Another option I thought of is to make <code>_logger</code> an object, with a <code>key</code> for each route, keyed on <code>req.url</code>. eg</p>
  
  <pre><code>_logger = {
    '/routeA': _logger(name: 'routeA'),
    '/routeB': _logger(name: 'routeB')
  }
  </code></pre>
  
  <p>But this feels a little messy.</p>