Add level to UTILS logs
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
132a8697b1
commit
ea50577946
@ -4,10 +4,10 @@ const san = require('../utils/sanitizer.utils') // Sanitiser
|
||||
|
||||
async function checkCrs(input){
|
||||
var INPUT = input.toUpperCase()
|
||||
log.out(`ldbUtils.checkCrs: Building database query to find: '${INPUT}'`)
|
||||
log.out(`ldbUtils.checkCrs: Building database query to find: '${INPUT}'`, "info")
|
||||
var query = {'$or':[{'3ALPHA':INPUT},{'TIPLOC':INPUT},{'STANOX':INPUT}]};
|
||||
var result = await db.query("stations", query)
|
||||
log.out(`ldbUtils.checkCrs: Query results: ${JSON.stringify(result)}`)
|
||||
log.out(`ldbUtils.checkCrs: Query results: ${JSON.stringify(result)}`, "info")
|
||||
return result
|
||||
}
|
||||
|
||||
@ -27,9 +27,9 @@ async function cleanMessages(input){ // Needs to be moved to the frontend `ensur
|
||||
async function cleanServices(input){ // Need to triple check but I don't think this is used anymore.
|
||||
var out = []
|
||||
if (!Array.isArray(input)) {
|
||||
log.out(`ldbUtils.cleanServices: Transforming input: ${input}`)
|
||||
log.out(`ldbUtils.cleanServices: Transforming input: ${input}`, "depr")
|
||||
out.push(input)
|
||||
log.out(`ldbUtils.cleanServices: Returning output: ${out}`)
|
||||
log.out(`ldbUtils.cleanServices: Returning output: ${out}`, "depr")
|
||||
return out;
|
||||
} else {
|
||||
return input;
|
||||
|
@ -1,11 +1,11 @@
|
||||
const environment = process.env.NODE_ENV;
|
||||
|
||||
async function out(msg, level = 'OTHR') {
|
||||
async function out(msg, level = 'othr') {
|
||||
if (environment === "production" && level === "info") {
|
||||
return;
|
||||
} else {
|
||||
const time = new Date().toISOString();
|
||||
console.log(`${time} - - ${level.toUpperCase()} - ${msg}`);
|
||||
console.log(`${time} - ${level.toUpperCase()} - ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ string.removeSpace("@abcd efgh"); // @abcdefgh
|
||||
function cleanApiEndpointTxt(input) {
|
||||
var output = clean.sanitize.keepSpace(input)
|
||||
if (output != input){
|
||||
log.out(`sanitizerUtils.cleanApiEndpoint: WARN: Sanitizing changed string. Input = ${input}`);
|
||||
log.out(`sanitizerUtils.cleanApiEndpoint: WARN: Sanitizing changed string. Input = ${input}`, "warn");
|
||||
}
|
||||
return output
|
||||
}
|
||||
@ -27,7 +27,7 @@ function cleanApiEndpointTxt(input) {
|
||||
function cleanApiEndpointNum(input) {
|
||||
var output = clean.sanitize.keepNumber(input)
|
||||
if (output != input){
|
||||
log.out(`sanitizerUtils.cleanApiEndpointNum: WARN: Sanitizing changed string. Input = ${input}`);
|
||||
log.out(`sanitizerUtils.cleanApiEndpointNum: WARN: Sanitizing changed string. Input = ${input}`, "warn");
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user