LAPI-310: Update error logs
This commit is contained in:
parent
cd1ba63c5a
commit
bbcaea217e
@ -7,7 +7,7 @@ address = 'https://hub.presgold.linx.safemobile.com/'
|
||||
|
||||
[api]
|
||||
port = ''
|
||||
host = 'presgold.linx.safemobile.com/apii'
|
||||
host = 'presgold.linx.safemobile.com/api'
|
||||
use_secure = true
|
||||
accept_untrusted_certs = true
|
||||
|
||||
|
41
src/asset.js
41
src/asset.js
@ -41,7 +41,7 @@ class Asset {
|
||||
utils.writeLog(`Asset ${this.id} was successfully initialized`)
|
||||
|
||||
if (err) {
|
||||
utils.writeErrorLog(`Asset ${this.id} was not successfully initialized`, err);
|
||||
utils.writeLog(`Asset ${this.id} was not successfully initialized`, err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -85,7 +85,8 @@ class Asset {
|
||||
|
||||
return this._getGroupsFromApi(callback);
|
||||
} else {
|
||||
utils.writeErrorLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -119,7 +120,8 @@ class Asset {
|
||||
utils.writeLog(`Informations about asset ${this.id} received`)
|
||||
return callback();
|
||||
} else {
|
||||
utils.writeErrorLog(`Error getting informations about asset ${this.id}`, error);
|
||||
utils.writeLog(`Error getting informations about asset ${this.id}`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -135,18 +137,24 @@ class Asset {
|
||||
|
||||
// Disconnect event
|
||||
hub.on('disconnect', () => {
|
||||
utils.writeLog(`Asset ${this.id} disconnected from HUB`)
|
||||
utils.writeLog(`Asset ${this.id} disconnected from HUB`);
|
||||
});
|
||||
let err = (e) => {
|
||||
utils.writeErrorLog(`Asset ${this.id} HUB connection error ${e}`);
|
||||
}
|
||||
hub.on('connect_timeout', err);
|
||||
hub.on('connect_error', err);
|
||||
|
||||
hub.on('connect_timeout', () => {
|
||||
utils.writeLog(`Asset ${this.id} connect_timeout from HUB`);
|
||||
utils.writeErrorLog(`ERROR_HUB`);
|
||||
});
|
||||
|
||||
hub.on('connect_error', () => {
|
||||
utils.writeLog(`Asset ${this.id} connect_error from HUB`);
|
||||
utils.writeErrorLog(`ERROR_HUB`);
|
||||
});
|
||||
|
||||
hub.once('connect', () => {
|
||||
return callback();
|
||||
});
|
||||
hub.on('connect', () => {
|
||||
utils.writeLog(`Asset ${this.id} connected to HUB`)
|
||||
utils.writeLog(`Asset ${this.id} connected to HUB`);
|
||||
this._sendArs();
|
||||
});
|
||||
|
||||
@ -182,7 +190,8 @@ class Asset {
|
||||
|
||||
this.mumble = new Mumble(this.id, this.configs, (err) => {
|
||||
if (err) {
|
||||
utils.writeErrorLog(`Asset ${this.id} Murmur connection error`, err);
|
||||
utils.writeLog(`Asset ${this.id} Murmur connection error`, err);
|
||||
utils.writeErrorLog(`ERROR_MURMUR`);
|
||||
return callback(err);
|
||||
} else {
|
||||
return callback();
|
||||
@ -203,7 +212,8 @@ class Asset {
|
||||
utils.writeLog(`Asset ${this.id} audio registered`);
|
||||
return callback();
|
||||
} else {
|
||||
utils.writeErrorLog(`Asset ${this.id} audio registered error`, error);
|
||||
utils.writeLog(`Asset ${this.id} audio registered error`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -239,7 +249,8 @@ class Asset {
|
||||
return callback('Cannot send group-monitoring: Hub not connected');
|
||||
}
|
||||
} else {
|
||||
utils.writeErrorLog(`Asset ${this.id} audio enter group error`, error);
|
||||
utils.writeLog(`Asset ${this.id} audio enter group error`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -291,7 +302,8 @@ class Asset {
|
||||
console.log(chalk.yellow(`[RECORDER] for asset ${this.id} not found`));
|
||||
}
|
||||
} else {
|
||||
utils.writeErrorLog(`Error getting record for asset ${this.id}`);
|
||||
utils.writeLog(`Error getting record for asset ${this.id}`);
|
||||
utils.writeErrorLog(`ERROR_RECORDER`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -337,6 +349,7 @@ class Asset {
|
||||
mp3.on('error', (e) => {
|
||||
utils.writeErrorLog(`Error _makePtt asset ${this.id}`, e);
|
||||
});
|
||||
|
||||
mp3.on('data', (data) => {
|
||||
|
||||
});
|
||||
|
@ -17,7 +17,6 @@ class Mumble {
|
||||
this.configs = configs;
|
||||
let mumble = configs.mumble;
|
||||
this._createCertificatesForUser(id, () => {
|
||||
|
||||
this._makeMumbleConnection(id, mumble.port, mumble.host, id, id, connectedCallback);
|
||||
})
|
||||
}
|
||||
@ -31,7 +30,7 @@ class Mumble {
|
||||
if (!fs.existsSync(path)) {
|
||||
utils.writeLog(`Creating certificates for asset ${id}`)
|
||||
try {
|
||||
var code = execSync(currentPath + '/createCerts.sh ' + id);
|
||||
code = execSync(currentPath + '/createCerts.sh ' + id);
|
||||
} catch (e) {
|
||||
return callback(false);
|
||||
}
|
||||
@ -50,7 +49,8 @@ class Mumble {
|
||||
utils.writeLog(`Creating certificates for Mumble`);
|
||||
try { execSync('./createCA.sh'); }
|
||||
catch(e) {
|
||||
utils.writeErrorLog(`Could not crete Mumble certificates. Error:${e}`);
|
||||
utils.writeLog(`Could not crete Mumble certificates. Error:${e}`);
|
||||
utils.writeErrorLog(`ERROR_MUMBLE`);
|
||||
throw 'Could not crete CA certificates. ' + e;
|
||||
}
|
||||
} else {
|
||||
@ -113,8 +113,8 @@ class Mumble {
|
||||
// never forget
|
||||
// console.log(err)
|
||||
// connectedCallback(err);
|
||||
console.log('Mumble _makeMumbleConnection ERROR')
|
||||
utils.writeErrorLog('Mumble _makeMumbleConnection ERROR', err);
|
||||
utils.writeLog('Mumble _makeMumbleConnection ERROR', err);
|
||||
utils.writeErrorLog(`ERROR_MUMBLE`);
|
||||
})
|
||||
.connect({ port: port, host: host, rejectUnauthorized: false, secureContext: secureContext });
|
||||
}
|
||||
|
@ -62,7 +62,8 @@ class Simulator {
|
||||
utils.writeLog(`Unregister assets: ${this.assetIds}`)
|
||||
return callback();
|
||||
} else {
|
||||
utils.writeErrorLog(`ERROR can't unregister users ${this.assetIds}`, error);
|
||||
utils.writeLog(`ERROR can't unregister users ${this.assetIds}`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ module.exports.writeLog = async (value) => {
|
||||
|
||||
module.exports.writeErrorLog = async (value) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
console.log(`ERROR: ${value}`);
|
||||
await fs.writeFile('./logs/error.log', `[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${value}\n`, {'flag':'a'}, (err) => {
|
||||
if (err) { reject(err); }
|
||||
else { resolve(); }
|
||||
|
Loading…
Reference in New Issue
Block a user