mirror of https://github.com/Fabio286/antares.git
feat: logging errors on log file
This commit is contained in:
parent
c3d96cb35b
commit
315d9d84c2
|
@ -19,7 +19,7 @@
|
|||
"@vueuse/core": "~10.4.1",
|
||||
"ace-builds": "~1.24.1",
|
||||
"better-sqlite3": "~9.1.1",
|
||||
"electron-log": "~4.4.1",
|
||||
"electron-log": "~5.0.1",
|
||||
"electron-store": "~8.1.0",
|
||||
"electron-updater": "~4.6.5",
|
||||
"electron-window-state": "~5.0.3",
|
||||
|
@ -6859,9 +6859,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/electron-log": {
|
||||
"version": "4.4.8",
|
||||
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-4.4.8.tgz",
|
||||
"integrity": "sha512-QQ4GvrXO+HkgqqEOYbi+DHL7hj5JM+nHi/j+qrN9zeeXVKy8ZABgbu4CnG+BBqDZ2+tbeq9tUC4DZfIWFU5AZA=="
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-5.0.1.tgz",
|
||||
"integrity": "sha512-x4wnwHg00h/onWQgjmvcdLV7Mrd9TZjxNs8LmXVpqvANDf4FsSs5wLlzOykWLcaFzR3+5hdVEQ8ctmrUxgHlPA==",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/electron-publish": {
|
||||
"version": "24.5.0",
|
||||
|
@ -22406,9 +22409,9 @@
|
|||
}
|
||||
},
|
||||
"electron-log": {
|
||||
"version": "4.4.8",
|
||||
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-4.4.8.tgz",
|
||||
"integrity": "sha512-QQ4GvrXO+HkgqqEOYbi+DHL7hj5JM+nHi/j+qrN9zeeXVKy8ZABgbu4CnG+BBqDZ2+tbeq9tUC4DZfIWFU5AZA=="
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-5.0.1.tgz",
|
||||
"integrity": "sha512-x4wnwHg00h/onWQgjmvcdLV7Mrd9TZjxNs8LmXVpqvANDf4FsSs5wLlzOykWLcaFzR3+5hdVEQ8ctmrUxgHlPA=="
|
||||
},
|
||||
"electron-publish": {
|
||||
"version": "24.5.0",
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
"@vueuse/core": "~10.4.1",
|
||||
"ace-builds": "~1.24.1",
|
||||
"better-sqlite3": "~9.1.1",
|
||||
"electron-log": "~4.4.1",
|
||||
"electron-log": "~5.0.1",
|
||||
"electron-store": "~8.1.0",
|
||||
"electron-updater": "~4.6.5",
|
||||
"electron-window-state": "~5.0.3",
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as path from 'path';
|
|||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||
const isFlatpak = process.platform === 'linux' && Boolean(process.env.FLATPAK_ID?.includes('fabiodistasio') || process.env.FLATPAK_ID?.includes('AntaresSQL'));
|
||||
const isFlatpak = process.platform === 'linux' && process.env.FLATPAK_ID;
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
let exporter: ChildProcessWithoutNullStreams = null;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ipcMain } from 'electron';
|
||||
import * as log from 'electron-log/main';
|
||||
import * as Store from 'electron-store';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
|
@ -59,7 +60,7 @@ export default () => {
|
|||
mainWindow.reply('update-downloaded');
|
||||
});
|
||||
|
||||
// autoUpdater.logger = require('electron-log');
|
||||
// autoUpdater.logger.transports.console.format = '{h}:{i}:{s} {text}';
|
||||
// autoUpdater.logger.transports.file.level = 'info';
|
||||
log.transports.file.level = 'info';
|
||||
// log.transports.console.format = '{h}:{i}:{s} {text}';
|
||||
autoUpdater.logger = log;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as remoteMain from '@electron/remote/main';
|
||||
import { app, BrowserWindow, ipcMain, nativeImage, safeStorage } from 'electron';
|
||||
import * as log from 'electron-log/main';
|
||||
import * as Store from 'electron-store';
|
||||
import * as windowStateKeeper from 'electron-window-state';
|
||||
import * as path from 'path';
|
||||
|
@ -8,6 +9,7 @@ import ipcHandlers from './ipc-handlers';
|
|||
import { OsMenu, ShortcutRegister } from './libs/ShortcutRegister';
|
||||
|
||||
Store.initRenderer();
|
||||
log.errorHandler.startCatching();
|
||||
const settingsStore = new Store({ name: 'settings' });
|
||||
const appTheme = settingsStore.get('application_theme');
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as antares from 'common/interfaces/antares';
|
||||
import * as log from 'electron-log/main';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { MySQLClient } from '../libs/clients/MySQLClient';
|
||||
|
@ -8,9 +9,13 @@ import MysqlExporter from '../libs/exporters/sql/MysqlExporter';
|
|||
import PostgreSQLExporter from '../libs/exporters/sql/PostgreSQLExporter';
|
||||
let exporter: antares.Exporter;
|
||||
|
||||
log.transports.file.fileName = 'workers.log';
|
||||
log.errorHandler.startCatching();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
process.on('message', async ({ type, client, tables, options }: any) => {
|
||||
if (type === 'init') {
|
||||
try {
|
||||
const connection = await ClientsFactory.getClient({
|
||||
client: client.name,
|
||||
params: client.config,
|
||||
|
@ -35,7 +40,7 @@ process.on('message', async ({ type, client, tables, options }: any) => {
|
|||
}
|
||||
|
||||
exporter.once('error', err => {
|
||||
console.error(err);
|
||||
log.error(err.toString());
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
|
@ -64,8 +69,14 @@ process.on('message', async ({ type, client, tables, options }: any) => {
|
|||
|
||||
exporter.run();
|
||||
}
|
||||
catch (err) {
|
||||
log.error(err.toString());
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (type === 'cancel')
|
||||
exporter.cancel();
|
||||
});
|
||||
|
||||
process.on('beforeExit', console.log);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import SSHConfig from '@fabio286/ssh2-promise/lib/sshConfig';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { ImportOptions } from 'common/interfaces/importer';
|
||||
import * as log from 'electron-log/main';
|
||||
import * as mysql from 'mysql2';
|
||||
import * as pg from 'pg';
|
||||
|
||||
|
@ -11,6 +12,9 @@ import MySQLImporter from '../libs/importers/sql/MySQLlImporter';
|
|||
import PostgreSQLImporter from '../libs/importers/sql/PostgreSQLImporter';
|
||||
let importer: antares.Importer;
|
||||
|
||||
log.transports.file.fileName = 'workers.log';
|
||||
log.errorHandler.startCatching();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
process.on('message', async ({ type, dbConfig, options }: {
|
||||
type: string;
|
||||
|
@ -49,7 +53,7 @@ process.on('message', async ({ type, dbConfig, options }: {
|
|||
}
|
||||
|
||||
importer.once('error', err => {
|
||||
console.error(err);
|
||||
log.error(err.toString());
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
|
@ -84,7 +88,7 @@ process.on('message', async ({ type, dbConfig, options }: {
|
|||
importer.run();
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
log.error(err.toString());
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
|
@ -94,19 +98,3 @@ process.on('message', async ({ type, dbConfig, options }: {
|
|||
else if (type === 'cancel')
|
||||
importer.cancel();
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error(err);
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error(err);
|
||||
process.send({
|
||||
type: 'error',
|
||||
payload: err.toString()
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue