Browse Source

Add index to log lines, and use it in sort

gre-patch-1
meriadec 6 years ago
parent
commit
0ea8b2cad8
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 10
      src/logger/logger.js

10
src/logger/logger.js

@ -23,8 +23,11 @@ require('winston-daily-rotate-file')
const { format } = winston
const { combine, json, timestamp } = format
let logIndex = 0
const pinfo = format(info => {
info.pname = pname
info.index = logIndex++
return info
})
@ -67,7 +70,12 @@ const queryAllLogs = async (date: Date = new Date()) => {
const all = internal
.concat(main)
.concat(renderer)
.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
.sort((a, b) => {
if (a.timestamp !== b.timestamp) {
return new Date(b.timestamp) - new Date(a.timestamp)
}
return b.index - a.index
})
return all
}

Loading…
Cancel
Save