apitally
Version:
Simple API monitoring & analytics for REST APIs built with Express, Fastify, NestJS, AdonisJS, Hono, H3, Elysia, and Koa.
42 lines (41 loc) • 1.16 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/loggers/utils.ts
import { format } from "util";
function formatMessage(message, ...args) {
return [
message,
...args
].map(formatArg).filter((arg) => arg !== "").join("\n");
}
__name(formatMessage, "formatMessage");
function removeKeys(obj, keys) {
return Object.fromEntries(Object.entries(obj).filter(([key]) => !keys.includes(key)));
}
__name(removeKeys, "removeKeys");
function formatArg(arg) {
if (typeof arg === "string") {
return arg.trim();
}
if (arg instanceof Error) {
return format(arg).trim();
}
if (arg === void 0 || arg === null || isEmptyObject(arg)) {
return "";
}
try {
return JSON.stringify(arg);
} catch {
return format(arg).trim();
}
}
__name(formatArg, "formatArg");
function isEmptyObject(obj) {
return obj !== null && typeof obj === "object" && Object.getPrototypeOf(obj) === Object.prototype && Object.keys(obj).length === 0;
}
__name(isEmptyObject, "isEmptyObject");
export {
formatMessage,
removeKeys
};
//# sourceMappingURL=utils.js.map