Seham Hammad
asked on
Log files in snappy ubuntu core
Hi
I am running Node.js app to check for connectivity and reboot if the timer reaches 0, and I am logging the status on a log file but when I run this code as a snap on ubuntu core, I can not find where the log files are in snap.
here is my code:
#!/usr/bin/env node
const moment = require('moment');
const shutdown = require('electron-shutdown -command') ;
const electron = require('electron');
const fs = require('fs');
let counter = 0;
function checkInternet(cb) {
setInterval(function(){
require('dns').lookup('goo gle.com',f unction(er r) {
if (err && err.code === "ENOTFOUND") {
cb(false);
} else {
cb(true);
}
}); }, 30000);
}
function rebootEdgeBox(){
shutdown.reboot();
console.log('Shutting down now');
}
checkInternet(function (isConnected) {
if (isConnected) {
console.log('alive');
counter =0;
} else {
const timeStamp = moment().format('YYYY-MM-D D, HH:mm:ss');
const status = 'Disconnected at ' + timeStamp;
console.log(status);
counter += 1;
vortexLog(status);
if (counter === 10){
counter = 0;
console.log('ji');
rebootEdgeBox();
}
}
});
function vortexLog(string) {
fs.appendFile('./Logs/conn ectionLog' , string + "\r\n", function (err) {
if (err) throw err;
});
}
I am running Node.js app to check for connectivity and reboot if the timer reaches 0, and I am logging the status on a log file but when I run this code as a snap on ubuntu core, I can not find where the log files are in snap.
here is my code:
#!/usr/bin/env node
const moment = require('moment');
const shutdown = require('electron-shutdown
const electron = require('electron');
const fs = require('fs');
let counter = 0;
function checkInternet(cb) {
setInterval(function(){
require('dns').lookup('goo
if (err && err.code === "ENOTFOUND") {
cb(false);
} else {
cb(true);
}
}); }, 30000);
}
function rebootEdgeBox(){
shutdown.reboot();
console.log('Shutting down now');
}
checkInternet(function (isConnected) {
if (isConnected) {
console.log('alive');
counter =0;
} else {
const timeStamp = moment().format('YYYY-MM-D
const status = 'Disconnected at ' + timeStamp;
console.log(status);
counter += 1;
vortexLog(status);
if (counter === 10){
counter = 0;
console.log('ji');
rebootEdgeBox();
}
}
});
function vortexLog(string) {
fs.appendFile('./Logs/conn
if (err) throw err;
});
}
ASKER
I have tried these two options, I can see the log file but its seems that the snap is not writting to the log
thanks
thanks
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
The file should be in the Log directory in the "current directory" where the process runs in.
This './Logs/connectionLog' sp[ecifies a file in the Current directory, then go down into Logs then check there for the file
connectionLog.
another option is:
find / -name connectionLog -ls
or more relevant:
find / -name connectionLog -ls | grep Logs