IO-2998 remove graylog and additional erroneous console logs.
This commit is contained in:
9
package-lock.json
generated
9
package-lock.json
generated
@@ -34,7 +34,6 @@
|
|||||||
"firebase-admin": "^12.5.0",
|
"firebase-admin": "^12.5.0",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.9.0",
|
||||||
"graphql-request": "^6.1.0",
|
"graphql-request": "^6.1.0",
|
||||||
"graylog2": "^0.2.1",
|
|
||||||
"inline-css": "^4.0.2",
|
"inline-css": "^4.0.2",
|
||||||
"intuit-oauth": "^4.1.2",
|
"intuit-oauth": "^4.1.2",
|
||||||
"ioredis": "^5.4.1",
|
"ioredis": "^5.4.1",
|
||||||
@@ -5338,14 +5337,6 @@
|
|||||||
"graphql": "14 - 16"
|
"graphql": "14 - 16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/graylog2": {
|
|
||||||
"version": "0.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/graylog2/-/graylog2-0.2.1.tgz",
|
|
||||||
"integrity": "sha512-vjysakwOhrAqMeIvSK0WZcmzKvkpxY6pCfT9QqtdSVAidPFIynuin7adqbdFp9MCCTbTE402WIxvg8cph5OWTA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.6.11"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/gtoken": {
|
"node_modules/gtoken": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.0.1.tgz",
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
"firebase-admin": "^12.5.0",
|
"firebase-admin": "^12.5.0",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.9.0",
|
||||||
"graphql-request": "^6.1.0",
|
"graphql-request": "^6.1.0",
|
||||||
"graylog2": "^0.2.1",
|
|
||||||
"inline-css": "^4.0.2",
|
"inline-css": "^4.0.2",
|
||||||
"intuit-oauth": "^4.1.2",
|
"intuit-oauth": "^4.1.2",
|
||||||
"ioredis": "^5.4.1",
|
"ioredis": "^5.4.1",
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ exports.default = async (req, res) => {
|
|||||||
|
|
||||||
res.status(200).json(ret);
|
res.status(200).json(ret);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
//console.log(error);
|
||||||
logger.log("qbo-receivable-create-error", "ERROR", req.user.email, {
|
logger.log("qbo-receivable-create-error", "ERROR", req.user.email, {
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ exports.lightbox_credentials = async (req, res) => {
|
|||||||
|
|
||||||
res.send(response.data);
|
res.send(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
//console.log(error);
|
||||||
logger.log("intellipay-lightbox-credentials-error", "ERROR", req.user?.email, null, {
|
logger.log("intellipay-lightbox-credentials-error", "ERROR", req.user?.email, null, {
|
||||||
error: JSON.stringify(error)
|
error: JSON.stringify(error)
|
||||||
});
|
});
|
||||||
@@ -109,7 +109,7 @@ exports.payment_refund = async (req, res) => {
|
|||||||
|
|
||||||
res.send(response.data);
|
res.send(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
//console.log(error);
|
||||||
logger.log("intellipay-refund-error", "ERROR", req.user?.email, null, {
|
logger.log("intellipay-refund-error", "ERROR", req.user?.email, null, {
|
||||||
error: JSON.stringify(error)
|
error: JSON.stringify(error)
|
||||||
});
|
});
|
||||||
@@ -143,7 +143,7 @@ exports.generate_payment_url = async (req, res) => {
|
|||||||
|
|
||||||
res.send(response.data);
|
res.send(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
//console.log(error);
|
||||||
logger.log("intellipay-payment-url-error", "ERROR", req.user?.email, null, {
|
logger.log("intellipay-payment-url-error", "ERROR", req.user?.email, null, {
|
||||||
error: JSON.stringify(error)
|
error: JSON.stringify(error)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ exports.default = async (req, res) => {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
ioRedis.to(getBodyshopRoom(bodyshopid)).emit("bodyshop-message", {
|
// ioRedis.to(getBodyshopRoom(bodyshopid)).emit("bodyshop-message", {
|
||||||
operationName,
|
// operationName,
|
||||||
useremail
|
// useremail
|
||||||
});
|
// });
|
||||||
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -866,8 +866,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("*** Taxable Amounts***");
|
// console.log("*** Taxable Amounts***");
|
||||||
console.table(JSON.parse(JSON.stringify(taxableAmounts)));
|
// console.table(JSON.parse(JSON.stringify(taxableAmounts)));
|
||||||
|
|
||||||
//For the taxable amounts, figure out which tax type applies.
|
//For the taxable amounts, figure out which tax type applies.
|
||||||
//Then sum up the total of that tax type and then calculate the thresholds.
|
//Then sum up the total of that tax type and then calculate the thresholds.
|
||||||
@@ -979,8 +979,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const remainingTaxableAmounts = taxableAmountsByTier;
|
const remainingTaxableAmounts = taxableAmountsByTier;
|
||||||
console.log("*** Taxable Amounts by Tier***");
|
// console.log("*** Taxable Amounts by Tier***");
|
||||||
console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
// console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
||||||
|
|
||||||
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
|
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
|
||||||
try {
|
try {
|
||||||
@@ -1030,8 +1030,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("*** Total Tax by Tier Amounts***");
|
// console.log("*** Total Tax by Tier Amounts***");
|
||||||
console.table(JSON.parse(JSON.stringify(totalTaxByTier)));
|
// console.table(JSON.parse(JSON.stringify(totalTaxByTier)));
|
||||||
|
|
||||||
stateTax = stateTax
|
stateTax = stateTax
|
||||||
.add(totalTaxByTier.ty1Tax)
|
.add(totalTaxByTier.ty1Tax)
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ async function AutoAddAtsIfRequired({ job, client }) {
|
|||||||
job.joblines[atsLineIndex].act_price = atsAmount;
|
job.joblines[atsLineIndex].act_price = atsAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(job.jobLines);
|
//console.log(job.jobLines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ async function OpenSearchUpdateHandler(req, res) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const response = await osClient.index(payload);
|
const response = await osClient.index(payload);
|
||||||
console.log(response.body);
|
//console.log(response.body);
|
||||||
res.status(200).json(response.body);
|
res.status(200).json(response.body);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -255,7 +255,7 @@ async function OpenSearchSearchHandler(req, res) {
|
|||||||
|
|
||||||
res.json(body);
|
res.json(body);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
//console.log(error);
|
||||||
logger.log("os-search-error", "ERROR", req.user.email, null, {
|
logger.log("os-search-error", "ERROR", req.user.email, null, {
|
||||||
error: JSON.stringify(error)
|
error: JSON.stringify(error)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
const { createCanvas } = require("canvas");
|
const { createCanvas } = require("canvas");
|
||||||
const Chart = require("chart.js/auto");
|
const Chart = require("chart.js/auto");
|
||||||
|
const logger = require("../utils/logger");
|
||||||
|
|
||||||
const { backgroundColors, borderColors } = require("./canvas-colors");
|
const { backgroundColors, borderColors } = require("./canvas-colors");
|
||||||
const { isObject, defaultsDeep, isNumber } = require("lodash");
|
const { isObject, defaultsDeep, isNumber } = require("lodash");
|
||||||
|
|
||||||
exports.canvastest = function (req, res) {
|
exports.canvastest = function (req, res) {
|
||||||
console.log("Incoming test request.", req);
|
//console.log("Incoming test request.", req);
|
||||||
res.status(200).send("OK");
|
res.status(200).send("OK");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.canvas = function (req, res) {
|
exports.canvas = function (req, res) {
|
||||||
const { w, h, values, keys, override } = req.body;
|
const { w, h, values, keys, override } = req.body;
|
||||||
console.log("Incoming Canvas Request:", w, h, values, keys, override);
|
//console.log("Incoming Canvas Request:", w, h, values, keys, override);
|
||||||
|
logger.log("inbound-canvas-creation", "debug", "jsr", null, { w, h, values, keys, override });
|
||||||
// Gate required values
|
// Gate required values
|
||||||
if (!values || !keys) {
|
if (!values || !keys) {
|
||||||
res.status(400).send("Missing required data");
|
res.status(400).send("Missing required data");
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ exports.receive = async (req, res) => {
|
|||||||
//Found a bodyshop - should always happen.
|
//Found a bodyshop - should always happen.
|
||||||
if (response.bodyshops[0].conversations.length === 0) {
|
if (response.bodyshops[0].conversations.length === 0) {
|
||||||
//No conversation Found, create one.
|
//No conversation Found, create one.
|
||||||
console.log("[SMS Receive] No conversation found. Creating one.");
|
//console.log("[SMS Receive] No conversation found. Creating one.");
|
||||||
newMessage.conversation = {
|
newMessage.conversation = {
|
||||||
data: {
|
data: {
|
||||||
bodyshopid: response.bodyshops[0].id,
|
bodyshopid: response.bodyshops[0].id,
|
||||||
@@ -56,7 +56,7 @@ exports.receive = async (req, res) => {
|
|||||||
};
|
};
|
||||||
} else if (response.bodyshops[0].conversations.length === 1) {
|
} else if (response.bodyshops[0].conversations.length === 1) {
|
||||||
//Just add it to the conversation
|
//Just add it to the conversation
|
||||||
console.log("[SMS Receive] Conversation found. Added ID.");
|
//console.log("[SMS Receive] Conversation found. Added ID.");
|
||||||
newMessage.conversationid = response.bodyshops[0].conversations[0].id;
|
newMessage.conversationid = response.bodyshops[0].conversations[0].id;
|
||||||
} else {
|
} else {
|
||||||
//We should never get here.
|
//We should never get here.
|
||||||
@@ -123,7 +123,14 @@ exports.receive = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e1) {
|
} catch (e1) {
|
||||||
console.log("e1", e1);
|
logger.log("sms-inbound-error", "ERROR", "api", null, {
|
||||||
|
msid: req.body.SmsMessageSid,
|
||||||
|
text: req.body.Body,
|
||||||
|
image: !!req.body.MediaUrl0,
|
||||||
|
image_path: generateMediaArray(req.body),
|
||||||
|
messagingServiceSid: req.body.MessagingServiceSid,
|
||||||
|
error: e1
|
||||||
|
});
|
||||||
res.sendStatus(500).json(e1);
|
res.sendStatus(500).json(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
const graylog2 = require("graylog2");
|
|
||||||
const InstanceManager = require("../utils/instanceMgr").default;
|
const InstanceManager = require("../utils/instanceMgr").default;
|
||||||
|
|
||||||
const logger = new graylog2.graylog({
|
|
||||||
servers: [{ host: "logs.bodyshop.app", port: 12201 }]
|
|
||||||
});
|
|
||||||
|
|
||||||
const winston = require("winston");
|
const winston = require("winston");
|
||||||
const WinstonCloudWatch = require("winston-cloudwatch");
|
const WinstonCloudWatch = require("winston-cloudwatch");
|
||||||
|
|
||||||
@@ -19,28 +13,47 @@ const winstonLogger = winston.createLogger({
|
|||||||
//level: "debug",
|
//level: "debug",
|
||||||
format: winston.format.json(),
|
format: winston.format.json(),
|
||||||
transports: [
|
transports: [
|
||||||
...(process.env.NODE_ENV !== "production" ? [new winston.transports.Console({ level: "silly" })] : []),
|
...(process.env.NODE_ENV !== "production"
|
||||||
new WinstonCloudWatch({
|
? [
|
||||||
level: "error",
|
new winston.transports.Console({
|
||||||
logGroupName: logGroupName,
|
level: "silly",
|
||||||
logStreamName: "errors",
|
format: winston.format.combine(
|
||||||
awsRegion: region,
|
winston.format.colorize(), // Colorize the output
|
||||||
jsonMessage: true
|
winston.format.timestamp(), // Add timestamps
|
||||||
}),
|
winston.format.printf(({ level, message, timestamp, user, record, object }) => {
|
||||||
new WinstonCloudWatch({
|
// Format the log message for pretty printing
|
||||||
level: "warn",
|
return `${timestamp} [${level}]: ${message} ${
|
||||||
logGroupName: logGroupName,
|
user ? `| user: ${JSON.stringify(user)}` : ""
|
||||||
logStreamName: "warn",
|
} ${record ? `| record: ${JSON.stringify(record)}` : ""} ${
|
||||||
awsRegion: region,
|
object ? `| object: ${JSON.stringify(object, null, 2)}` : ""
|
||||||
jsonMessage: true
|
}`;
|
||||||
}),
|
})
|
||||||
new WinstonCloudWatch({
|
)
|
||||||
level: "debug",
|
})
|
||||||
logGroupName: logGroupName,
|
]
|
||||||
logStreamName: "debug",
|
: [
|
||||||
awsRegion: region,
|
new WinstonCloudWatch({
|
||||||
jsonMessage: true
|
level: "error",
|
||||||
})
|
logGroupName: logGroupName,
|
||||||
|
logStreamName: "errors",
|
||||||
|
awsRegion: region,
|
||||||
|
jsonMessage: true
|
||||||
|
}),
|
||||||
|
new WinstonCloudWatch({
|
||||||
|
level: "warn",
|
||||||
|
logGroupName: logGroupName,
|
||||||
|
logStreamName: "warn",
|
||||||
|
awsRegion: region,
|
||||||
|
jsonMessage: true
|
||||||
|
}),
|
||||||
|
new WinstonCloudWatch({
|
||||||
|
level: "debug",
|
||||||
|
logGroupName: logGroupName,
|
||||||
|
logStreamName: "debug",
|
||||||
|
awsRegion: region,
|
||||||
|
jsonMessage: true
|
||||||
|
})
|
||||||
|
])
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,15 +65,9 @@ function log(message, type, user, record, object) {
|
|||||||
message: message,
|
message: message,
|
||||||
user: user,
|
user: user,
|
||||||
record: record,
|
record: record,
|
||||||
object: object
|
meta: object
|
||||||
});
|
});
|
||||||
// logger.log(message, message, {
|
|
||||||
// type,
|
|
||||||
// env: process.env.NODE_ENV || "development",
|
|
||||||
// user,
|
|
||||||
// record,
|
|
||||||
// ...object
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { log };
|
module.exports = { log };
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const redisSocketEvents = ({
|
|||||||
}) => {
|
}) => {
|
||||||
// Logging helper functions
|
// Logging helper functions
|
||||||
const createLogEvent = (socket, level, message) => {
|
const createLogEvent = (socket, level, message) => {
|
||||||
console.log(`[IOREDIS LOG EVENT] - ${socket?.user?.email} - ${socket.id} - ${message}`);
|
//console.log(`[IOREDIS LOG EVENT] - ${socket?.user?.email} - ${socket.id} - ${message}`);
|
||||||
logger.log("ioredis-log-event", level, socket?.user?.email, null, { wsmessage: message });
|
logger.log("ioredis-log-event", level, socket?.user?.email, null, { wsmessage: message });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ const redisSocketEvents = ({
|
|||||||
next(new Error("Authentication error - no authorization token."));
|
next(new Error("Authentication error - no authorization token."));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Uncaught connection error:::", error);
|
//console.log("Uncaught connection error:::", error);
|
||||||
logger.log("websocket-connection-error", "error", null, null, {
|
logger.log("websocket-connection-error", "error", null, null, {
|
||||||
...error
|
...error
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ io.use(function (socket, next) {
|
|||||||
next(new Error("Authentication error - no authorization token."));
|
next(new Error("Authentication error - no authorization token."));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Uncaught connection error:::", error);
|
//console.log("Uncaught connection error:::", error);
|
||||||
logger.log("websocket-connection-error", "error", null, null, {
|
logger.log("websocket-connection-error", "error", null, null, {
|
||||||
token: socket.handshake.auth.token,
|
token: socket.handshake.auth.token,
|
||||||
...error
|
...error
|
||||||
@@ -148,7 +148,7 @@ function createLogEvent(socket, level, message) {
|
|||||||
|
|
||||||
function createJsonEvent(socket, level, message, json) {
|
function createJsonEvent(socket, level, message, json) {
|
||||||
if (LogLevelHierarchy(socket.log_level) >= LogLevelHierarchy(level)) {
|
if (LogLevelHierarchy(socket.log_level) >= LogLevelHierarchy(level)) {
|
||||||
console.log(`[WS LOG EVENT] ${level} - ${new Date()} - ${socket.user.email} - ${socket.id} - ${message}`);
|
//console.log(`[WS LOG EVENT] ${level} - ${new Date()} - ${socket.user.email} - ${socket.id} - ${message}`);
|
||||||
socket.emit("log-event", {
|
socket.emit("log-event", {
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
level,
|
level,
|
||||||
|
|||||||
Reference in New Issue
Block a user