forked from apxtri/apxtri
29 lines
865 B
JavaScript
29 lines
865 B
JavaScript
const fs = require("fs-extra");
|
|
const dayjs = require("dayjs");
|
|
const conf = require(`../../../../conf/townconf.json`);
|
|
const l = {};
|
|
l.context="";
|
|
l.og = (...infos) => {
|
|
// in apxtowns/towns/conf/townconf.json .api.activelog a list of context to log
|
|
// usage:
|
|
// const l=require('./tools/log.js');
|
|
// 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);
|
|
}
|
|
|
|
//console.assert(conf.api.activelog.includes(l.context),infos)
|
|
|
|
};
|
|
|
|
l.ogprod = (tribe,info) => {
|
|
const logf = `../../tribes/${tribe}/logs/apxtri/apxtri_${tribe}.log`;
|
|
const msg = `${days.js().toISOString()}###${l.context}###${tribe}###${info}`;
|
|
fs.appendFileSync(logf, msg);
|
|
console.log(msg)
|
|
};
|
|
|
|
module.exports = l;
|