Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. const bunyan = require('bunyan')
  2. const mongoose = require('mongoose')
  3. const Schema = mongoose.Schema;
  4.  
  5. const Log = mongoose.model('Log', new Schema({
  6. name: String,
  7. hostname: String,
  8. pid: Number,
  9. level: Number,
  10. msg: String,
  11. time: { type: Date, index: true },
  12. v: Number,
  13. }, {
  14. versionKey: 'ver',
  15. }));
  16.  
  17. const LogStream = class {
  18. write(rec) {
  19. try { new Log(JSON.parse(rec)).save() }
  20. catch(e) { console.error(e) }
  21. }
  22. }
  23.  
  24. const log = bunyan.createLogger({
  25. name: "tamuro.api",
  26. streams: [{stream: new LogStream()}]
  27. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement