mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 11:46:27 +00:00
Compare commits
2 Commits
develop_v1.6.6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f9511157f | |||
| be59fbb9e2 |
@@ -134,24 +134,20 @@ const logger = {
|
|||||||
console.log(statusCode);
|
console.log(statusCode);
|
||||||
winstonLoki.log.error({
|
winstonLoki.log.error({
|
||||||
message: message,
|
message: message,
|
||||||
labels: {
|
route: url,
|
||||||
route: url,
|
status_code: statusCode,
|
||||||
status_code: statusCode,
|
issuer_name: issuerName,
|
||||||
issuer_name: issuerName,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let reservation_number = info.meta.res.body.data.reservation_number;
|
let reservation_number = info.meta.res.body.data.reservation_number;
|
||||||
let card_number = info.meta.res.body.data.card_number;
|
let card_number = info.meta.res.body.data.card_number;
|
||||||
winstonLoki.log.info({
|
winstonLoki.log.info({
|
||||||
message: message,
|
message: message,
|
||||||
labels: {
|
route: url,
|
||||||
route: url,
|
status_code: statusCode,
|
||||||
status_code: statusCode,
|
issuer_name: issuerName,
|
||||||
issuer_name: issuerName,
|
reservation_number: reservation_number,
|
||||||
reservation_number: reservation_number,
|
card_number: card_number,
|
||||||
card_number: card_number,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (url == "/api/topup6" || url == "/api/topup7") {
|
} else if (url == "/api/topup6" || url == "/api/topup7") {
|
||||||
@@ -167,26 +163,22 @@ const logger = {
|
|||||||
) {
|
) {
|
||||||
winstonLoki.log.error({
|
winstonLoki.log.error({
|
||||||
message: message,
|
message: message,
|
||||||
labels: {
|
route: url,
|
||||||
route: url,
|
status_code: statusCode,
|
||||||
status_code: statusCode,
|
issuer_name: issuerName,
|
||||||
issuer_name: issuerName,
|
card_number: card_number,
|
||||||
card_number: card_number,
|
uid: uid,
|
||||||
uid: uid,
|
trxID: trxID,
|
||||||
trxID: trxID,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
winstonLoki.log.info({
|
winstonLoki.log.info({
|
||||||
message: message,
|
message: message,
|
||||||
labels: {
|
route: url,
|
||||||
route: url,
|
status_code: statusCode,
|
||||||
status_code: statusCode,
|
issuer_name: issuerName,
|
||||||
issuer_name: issuerName,
|
card_number: card_number,
|
||||||
card_number: card_number,
|
uid: uid,
|
||||||
uid: uid,
|
trxID: trxID,
|
||||||
trxID: trxID,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -200,22 +192,18 @@ const logger = {
|
|||||||
) {
|
) {
|
||||||
winstonLoki.log.error({
|
winstonLoki.log.error({
|
||||||
message: message,
|
message: message,
|
||||||
labels: {
|
route: url,
|
||||||
route: url,
|
status_code: statusCode,
|
||||||
status_code: statusCode,
|
issuer_name: issuerName,
|
||||||
issuer_name: issuerName,
|
trxID: trxID,
|
||||||
trxID: trxID,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
winstonLoki.log.info({
|
winstonLoki.log.info({
|
||||||
message: message,
|
message: message,
|
||||||
labels: {
|
route: url,
|
||||||
route: url,
|
status_code: statusCode,
|
||||||
status_code: statusCode,
|
issuer_name: issuerName,
|
||||||
issuer_name: issuerName,
|
trxID: trxID,
|
||||||
trxID: trxID,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-21
@@ -1,8 +1,8 @@
|
|||||||
const moment = require('moment');
|
const moment = require("moment");
|
||||||
const winston = require('winston');
|
const winston = require("winston");
|
||||||
const loki = require('winston-loki');
|
const loki = require("winston-loki");
|
||||||
require('winston-daily-rotate-file');
|
require("winston-daily-rotate-file");
|
||||||
require('dotenv').config();
|
require("dotenv").config();
|
||||||
const { combine, timestamp, printf, colorize, align, json } = winston.format;
|
const { combine, timestamp, printf, colorize, align, json } = winston.format;
|
||||||
let lokiUrl = process.env.LOKI_URL;
|
let lokiUrl = process.env.LOKI_URL;
|
||||||
|
|
||||||
@@ -18,39 +18,39 @@ var log;
|
|||||||
|
|
||||||
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
||||||
filename: `./lokiLog/%DATE%-onlinetopup.log`,
|
filename: `./lokiLog/%DATE%-onlinetopup.log`,
|
||||||
datePattern: 'YYYY-MM-DD',
|
datePattern: "YYYY-MM-DD",
|
||||||
maxFiles: '1d',
|
maxFiles: "1d",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
process.env.NODE_ENV == 'production' ||
|
process.env.NODE_ENV == "production" ||
|
||||||
process.env.NODE_ENV == 'PRODUCTION'
|
process.env.NODE_ENV == "PRODUCTION"
|
||||||
) {
|
) {
|
||||||
log = winston.createLogger({
|
log = winston.createLogger({
|
||||||
levels: logLevels,
|
levels: logLevels,
|
||||||
level: process.env.LOG_LEVEL || 'info',
|
level: process.env.LOG_LEVEL || "info",
|
||||||
exitOnError: false,
|
exitOnError: false,
|
||||||
// format: combine(timestamp(), json()),
|
// format: combine(timestamp(), json()),
|
||||||
format: combine(
|
format: combine(
|
||||||
// colorize({ all: true }),
|
// colorize({ all: true }),
|
||||||
timestamp({
|
timestamp({
|
||||||
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
format: "YYYY-MM-DD HH:mm:ss.SSS",
|
||||||
}),
|
}),
|
||||||
align(),
|
align(),
|
||||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`),
|
||||||
),
|
),
|
||||||
defaultMeta: { service: 'topuponline' },
|
defaultMeta: { service: "topuponline" },
|
||||||
transports: [
|
transports: [
|
||||||
new loki({
|
new loki({
|
||||||
host: lokiUrl,
|
host: lokiUrl,
|
||||||
labels: { app: 'topuponline' },
|
labels: { app: "topuponline" },
|
||||||
json: true,
|
json: true,
|
||||||
format: json(),
|
format: json(),
|
||||||
replaceTimestamp: true,
|
replaceTimestamp: true,
|
||||||
onConnectionError: (err) => console.error(err),
|
onConnectionError: (err) => console.error(err),
|
||||||
}),
|
}),
|
||||||
new transports.Console({
|
new winston.transports.Console({
|
||||||
format: format.combine(format.simple(), format.colorize()),
|
format: combine(colorize()),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -59,7 +59,7 @@ if (
|
|||||||
transports: [
|
transports: [
|
||||||
new loki({
|
new loki({
|
||||||
host: lokiUrl,
|
host: lokiUrl,
|
||||||
labels: { app: 'topuponline' },
|
labels: { app: "topuponline" },
|
||||||
handleExceptions: true,
|
handleExceptions: true,
|
||||||
handleRejections: true,
|
handleRejections: true,
|
||||||
clearOnError: true,
|
clearOnError: true,
|
||||||
@@ -75,19 +75,19 @@ if (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV != 'testing' && process.env.NODE_ENV != 'TESTING') {
|
if (process.env.NODE_ENV != "testing" && process.env.NODE_ENV != "TESTING") {
|
||||||
log.add(
|
log.add(
|
||||||
new winston.transports.Console({
|
new winston.transports.Console({
|
||||||
// format: winston.format.cli(),
|
// format: winston.format.cli(),
|
||||||
format: combine(
|
format: combine(
|
||||||
colorize({ all: true }),
|
colorize({ all: true }),
|
||||||
timestamp({
|
timestamp({
|
||||||
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
format: "YYYY-MM-DD HH:mm:ss.SSS",
|
||||||
}),
|
}),
|
||||||
align(),
|
align(),
|
||||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`),
|
||||||
),
|
),
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user