Skip to content
Snippets Groups Projects
Commit f1552965 authored by timothycarambat's avatar timothycarambat
Browse files

patch logger for full logs

parent cec1a3d5
No related branches found
No related merge requests found
......@@ -30,17 +30,28 @@ class Logger {
],
});
console.log = function () {
return logger.info.apply(logger, arguments);
function formatArgs(args) {
return args
.map((arg) => {
if (arg instanceof Error) {
return arg.stack; // If argument is an Error object, return its stack trace
} else if (typeof arg === "object") {
return JSON.stringify(arg); // Convert objects to JSON string
} else {
return arg; // Otherwise, return as-is
}
})
.join(" ");
}
console.log = function (...args) {
logger.info(formatArgs(args));
};
console.error = function () {
if (arguments.length > 0 && arguments[0] instanceof Error) {
return logger.error(arguments[0].stack);
}
return logger.error.apply(logger, arguments);
console.error = function (...args) {
logger.error(formatArgs(args));
};
console.info = function () {
return logger.warn.apply(logger, arguments);
console.info = function (...args) {
logger.warn(formatArgs(args));
};
return logger;
}
......
......@@ -28,17 +28,28 @@ class Logger {
],
});
console.log = function () {
return logger.info.apply(logger, arguments);
function formatArgs(args) {
return args
.map((arg) => {
if (arg instanceof Error) {
return arg.stack; // If argument is an Error object, return its stack trace
} else if (typeof arg === "object") {
return JSON.stringify(arg); // Convert objects to JSON string
} else {
return arg; // Otherwise, return as-is
}
})
.join(" ");
}
console.log = function (...args) {
logger.info(formatArgs(args));
};
console.error = function () {
if (arguments.length > 0 && arguments[0] instanceof Error) {
return logger.error(arguments[0].stack);
}
return logger.error.apply(logger, arguments);
console.error = function (...args) {
logger.error(formatArgs(args));
};
console.info = function () {
return logger.warn.apply(logger, arguments);
console.info = function (...args) {
logger.warn(formatArgs(args));
};
return logger;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment