Browse Source

Merge pull request #1087 from gre/fix-logger

Fix 'Export Logs' to work without the .gz feature (buggy)
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
e1d208a51c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/components/ExportLogsBtn.js
  2. 21
      src/logger/logger.js

3
src/components/ExportLogsBtn.js

@ -33,6 +33,7 @@ class ExportLogsBtn extends Component<{
environment: __DEV__ ? 'development' : 'production',
userAgent: window.navigator.userAgent,
})
const date = new Date() // we don't want all the logs that happen after the Export was pressed ^^
const path = remote.dialog.showSaveDialog({
title: 'Export logs',
defaultPath: `ledgerlive-export-${moment().format(
@ -46,7 +47,7 @@ class ExportLogsBtn extends Component<{
],
})
if (path) {
const logs = await logger.queryAllLogs()
const logs = await logger.queryAllLogs(date)
const json = JSON.stringify(logs)
await writeToFile(path, json)
}

21
src/logger/logger.js

@ -32,23 +32,22 @@ function createDailyRotateFile(processName) {
return new winston.transports.DailyRotateFile({
dirname: resolveLogsDirectory(),
json: true,
zippedArchive: true,
filename: `ledger-live-${processName}-%DATE%.log`,
datePattern: 'YYYY-MM-DD',
maxSize: '10m',
maxFiles: '14d',
maxSize: '20m',
maxFiles: '7d',
})
}
const transports = [createDailyRotateFile(pname)]
const queryLogs = (processName: string) =>
const queryLogs = (processName: string, date: Date) =>
new Promise((resolve, reject) => {
const dailyRotateFile = createDailyRotateFile(processName)
const options = {
from: new Date() - 60 * 60 * 1000,
until: new Date(),
limit: 100,
from: date - 10 * 60 * 1000,
until: date,
limit: 500,
start: 0,
order: 'desc',
}
@ -61,10 +60,10 @@ const queryLogs = (processName: string) =>
})
})
const queryAllLogs = async () => {
const internal = await queryLogs('internal')
const main = await queryLogs('main')
const renderer = await queryLogs('renderer')
const queryAllLogs = async (date: Date = new Date()) => {
const internal = await queryLogs('internal', date)
const main = await queryLogs('main', date)
const renderer = await queryLogs('renderer', date)
const all = internal
.concat(main)
.concat(renderer)

Loading…
Cancel
Save