2023-12-29 13:38:47 +01:00
|
|
|
const fs = require("fs-extra");
|
|
|
|
const dayjs = require("dayjs");
|
2024-03-15 08:49:23 +01:00
|
|
|
const conf = require(`../../../../conf/townconf.json`);
|
2023-12-29 13:38:47 +01:00
|
|
|
const l = {};
|
|
|
|
l.context="";
|
|
|
|
l.og = (...infos) => {
|
2024-02-16 08:39:42 +01:00
|
|
|
// in apxtowns/towns/conf/townconf.json .api.activelog a list of context to log
|
2023-12-29 13:38:47 +01:00
|
|
|
// usage:
|
|
|
|
// const l=require('./tools/log.js');
|
2024-02-16 08:39:42 +01:00
|
|
|
// l.context="apxtri"; // name of model route to find it easily
|
|
|
|
// then l.og(str1,str2,array1,objet,...)
|
|
|
|
//console.log(infos)
|
|
|
|
if (conf.api.activelog.includes(l.context)) {
|
|
|
|
console.log(l.context,'-', ...infos);
|
2023-12-29 13:38:47 +01:00
|
|
|
}
|
2024-02-16 08:39:42 +01:00
|
|
|
|
|
|
|
//console.assert(conf.api.activelog.includes(l.context),infos)
|
|
|
|
|
2023-12-29 13:38:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
l.ogprod = (tribe,info) => {
|
2024-03-15 08:49:23 +01:00
|
|
|
const logf = `../../tribes/${tribe}/logs/apxtri/apxtri_${tribe}.log`;
|
2024-02-16 08:39:42 +01:00
|
|
|
const msg = `${days.js().toISOString()}###${l.context}###${tribe}###${info}`;
|
2023-12-29 13:38:47 +01:00
|
|
|
fs.appendFileSync(logf, msg);
|
|
|
|
console.log(msg)
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = l;
|