title: Log a mongoose db entry using winston - node js
body: <p>I have a schema:</p>
  
  <pre><code>var nameSchema = new Schema({
    name: String,
    surname: String,
    word: String
  })
  var nameSchema = mongoose.model('nameSchema', nameSchema)
  </code></pre>
  
  <p>Which updates my dbs fields every time I run my code. This is what my dbs entry looks like:</p>
  
  <pre><code>{ "_id" : ObjectId("xxx"), "name" : "Tom", "surname" : "Qwerty", "word" : "secret", "__v" : 0 }
  </code></pre>
  
  <p>Now once this dbs entry is saved successfully, I want to make a winston log too, passing this dbs information to the log. So it will look something like this:</p>
  
  <pre><code> var logger = new (winston.Logger)({
      transports: [
        new (winston.transports.File)({
          filename: './logs/example.log',
          level: 'info',
          timestamp: true,
          event: 'MY DBS ENTRY'   
        })
      ]
    });
  </code></pre>
  
  <p>My thinking is around these line...</p>
  
  <pre><code>logger.log('info', "db.?? -NOT SURE");
  </code></pre>
  
  <p>So the log file would look like this:</p>
  
  <pre><code>{"level":"info","event":"{"name" : "Tom", "surname" : "Qwerty", "word" : "secret"}","timestamp":"2016-08-11T10:44:49.527Z"}
  </code></pre>
  
  <p>Any help or tips appreciated</p>