Skip to content
Extraits de code Groupes Projets
Vérifiée Valider a16eaf10 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

INSTANCE: Add the logger for all the application

Will write averything to a file 'lektor-app.log' and output it to stdout.
parent ae0822c9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!3Dev kubat,!2Base interface and system
Copyright 2020 to Lektor App contributors
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice with the CONTRIBUTORS file and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
......@@ -10,4 +11,4 @@ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
\ No newline at end of file
THIS SOFTWARE.
......@@ -30,17 +30,13 @@ const __loggerCustomLevels = {
}
};
var transport;
if (fs.existsSync("/dev/stderr")) {
/* /dev/stderr exists */
transport = new winston.transports.Stream({stream: fs.createWriteStream('/dev/stderr')});
} else {
/* No /dev/stderr, may be windob' */
transport = new winston.transports.Console();
}
module.exports = global.logger = module.exports = winston.createLogger({
transports: [ transport ],
var logger = winston.createLogger({
transports: [ new winston.transports.File({
eol: "\n",
filename: "./lektor-app.log",
maxsize: "10M",
tailable: true,
}) ],
level: "debug",
json: false,
handleExceptions: true,
......@@ -55,3 +51,7 @@ module.exports = global.logger = module.exports = winston.createLogger({
})
)
});
Object.assign(logger, {logfile: "./lektor-app.log"});
module.exports = global.logger = module.exports = logger;
......@@ -3,9 +3,9 @@ const logger = require('../common/logger.js');
const karaJSON = require('../test/dummyKara.json');
const buttonList = [
[ "left", "Play", "commandPlay" ],
[ "left", "Stop", "commandStop" ],
[ "right", "Quit LektorApp", "closeButton" ]
[ "left", "Play", "commandPlay" ],
[ "left", "Stop", "commandStop" ],
[ "right", "Quit LektorApp", "closeButton" ]
];
window.onload = () => {
......
......@@ -2,13 +2,20 @@ const logger = require.main.require('./common/logger.js');
const electron = require('electron')
const { app, BrowserWindow } = require('electron')
const { ipcMain } = require('electron')
const { fork } = require('child_process');
const { fork, spawn } = require('child_process');
const fs = require("fs");
var tail = require('tail').Tail;
var client; /* Sub process for the express server */
/* Sub process for the express server */
var client;
/* Reinit the logfile */
fs.truncate(logger.logfile, 0, () => {});
var tail = new tail(logger.logfile);
/** Creates the main window and process for the admin interface
*/
tail.on("line", function(data) {
console.log(data);
});
/* Creates the main window and process for the admin interface */
function createInstanceWindow () {
const win = new BrowserWindow({
width: 1280,
......@@ -20,7 +27,7 @@ function createInstanceWindow () {
})
win.loadFile('instance/index.html');
win.webContents.openDevTools();
// win.webContents.openDevTools();
}
ipcMain.on('close-app', (evt, arg) => {
......@@ -28,6 +35,7 @@ ipcMain.on('close-app', (evt, arg) => {
})
app.on("quit", () => {
logger.info("Send SIGTERM to express process and tailler process");
client.kill("SIGTERM");
});
......@@ -36,3 +44,4 @@ app.on('ready', () => {
createInstanceWindow();
client = fork('client/main.js');
});
......@@ -11,13 +11,15 @@
],
"license": "ISC",
"scripts": {
"start": "electron ."
"start": "electron .",
"test": "ELECTRON_ENABLE_LOGGING=0 ELECTRON_NO_ATTACH_CONSOLE=true electron ."
},
"dependencies": {
"ejs": "^3.1.5",
"electron": "^10.1.1",
"express": "^4.17.1",
"sqlite3": "^5.0.0",
"tail": "^2.0.4",
"winston": "^3.3.3"
},
"config": {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter