title: Log message as express app.listen callback
body: <p>I am introducing winston logging into my application and i would like to replace all info or error level logs with winston's <code>.info</code> and <code>.error</code>. So far everything works except when I try and log a info message from within app.listen callback.</p>
  
  <p><code>appStartup.js</code> file where logger is defined</p>
  
  <pre><code>const app = require('express')();
  const co = require('co');
  const cors = require('cors');
  const winston = require('winston');
  
  const loggerTimeFormat = () =&gt; (new Date()).toLocaleTimeString();
  
  const winstonLogger = new winston.Logger({
    transports: [
      new winston.transports.Console({
        timestamp: loggerTimeFormat,
      }),
    ],
  });
  
  module.exports = function appStartup() {
    co(function* services() {
      app.db = mongo.connect();
      app.use(cors());
      app.set('logger', winstonLogger);
    }).catch((e) =&gt; {
      console.error(e);
    });
  
    return app;
  };
  </code></pre>
  
  <p>In my <code>server.js</code> file I have:</p>
  
  <pre><code>const app = require('./src/appStartup');
  
  const appPort = process.env.PORT;
  app().listen(appPort, () =&gt; {
    console.log('Info message here');
  });
  </code></pre>
  
  <p>I would like to replace the <code>console.log</code> in <code>server.js</code> with a winston <code>info</code> log I tried doing this:</p>
  
  <pre><code>const app = require('./src/appStartup');
  const appPort = process.env.PORT;
  const appObj = app();
  
  appObj.listen(appPort, (appObj.get('logger')) =&gt; {
    logger.info('Info message here');
  });
  </code></pre>
  
  <p>Not sure if that's the right syntax though, I get <code>Parsing error: Assigned to rvalue</code> for <code>appObj</code> in <code>appObj.get('logger')</code>. Any idea how can I make this work?</p>