@cloudnux/local-cloud-provider 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-console-plugin/index.js +52 -52
- package/dist/dev-console-plugin/index.js.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/dist/queue-plugin/index.js +20 -17
- package/dist/queue-plugin/index.js.map +1 -1
- package/dist/schedule-plugin/index.js +9 -7
- package/dist/schedule-plugin/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1002,12 +1002,18 @@ var errorToString = (error) => {
|
|
|
1002
1002
|
|
|
1003
1003
|
// ../../utils/src/logging/index.ts
|
|
1004
1004
|
var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
|
|
1005
|
+
var module = "default";
|
|
1006
|
+
var requestId = "";
|
|
1007
|
+
function initializeLogger(moduleName, requestIdValue = "") {
|
|
1008
|
+
module = moduleName;
|
|
1009
|
+
requestId = requestIdValue;
|
|
1010
|
+
}
|
|
1005
1011
|
var logger = {
|
|
1006
1012
|
fatal: (message, meta) => {
|
|
1007
1013
|
if (currentLogLevel >= logLevels.fatal) {
|
|
1008
1014
|
console.error(
|
|
1009
1015
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1010
|
-
`${chalk.bgRed.white(" fatal ")}${EOL}`,
|
|
1016
|
+
`${chalk.bgRed.white(" fatal ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1011
1017
|
errorToString(message),
|
|
1012
1018
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1013
1019
|
);
|
|
@@ -1017,7 +1023,7 @@ var logger = {
|
|
|
1017
1023
|
if (currentLogLevel >= logLevels.error) {
|
|
1018
1024
|
console.error(
|
|
1019
1025
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1020
|
-
`${chalk.bgRed.white(" error ")}${EOL}`,
|
|
1026
|
+
`${chalk.bgRed.white(" error ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1021
1027
|
errorToString(message),
|
|
1022
1028
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1023
1029
|
);
|
|
@@ -1027,7 +1033,7 @@ var logger = {
|
|
|
1027
1033
|
if (currentLogLevel >= logLevels.warn) {
|
|
1028
1034
|
console.warn(
|
|
1029
1035
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1030
|
-
`${chalk.bgYellow.black(" warn ")}${EOL}`,
|
|
1036
|
+
`${chalk.bgYellow.black(" warn ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1031
1037
|
errorToString(message),
|
|
1032
1038
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1033
1039
|
);
|
|
@@ -1037,7 +1043,7 @@ var logger = {
|
|
|
1037
1043
|
if (currentLogLevel >= logLevels.info) {
|
|
1038
1044
|
console.info(
|
|
1039
1045
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1040
|
-
`${chalk.bgBlue.white(" info ")}${EOL}`,
|
|
1046
|
+
`${chalk.bgBlue.white(" info ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1041
1047
|
message,
|
|
1042
1048
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1043
1049
|
);
|
|
@@ -1047,7 +1053,7 @@ var logger = {
|
|
|
1047
1053
|
if (currentLogLevel >= logLevels.debug) {
|
|
1048
1054
|
console.debug(
|
|
1049
1055
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1050
|
-
`${chalk.bgWhite.black(" debug ")}${EOL}`,
|
|
1056
|
+
`${chalk.bgWhite.black(" debug ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1051
1057
|
message,
|
|
1052
1058
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1053
1059
|
);
|
|
@@ -1798,7 +1804,16 @@ import fastifyPrintRoutes from "fastify-print-routes";
|
|
|
1798
1804
|
function createRouter(options = {}) {
|
|
1799
1805
|
const fastify = Fastify({
|
|
1800
1806
|
maxParamLength: 1e3,
|
|
1801
|
-
logger: options.logger
|
|
1807
|
+
logger: options.logger ? {
|
|
1808
|
+
transport: {
|
|
1809
|
+
target: "pino-pretty",
|
|
1810
|
+
options: {
|
|
1811
|
+
colorize: true,
|
|
1812
|
+
translateTime: "HH:MM:ss Z",
|
|
1813
|
+
ignore: "pid,hostname"
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
} : void 0
|
|
1802
1817
|
});
|
|
1803
1818
|
fastify.register(fastifyRawBody, {
|
|
1804
1819
|
field: "rawBody",
|
|
@@ -1809,6 +1824,14 @@ function createRouter(options = {}) {
|
|
|
1809
1824
|
fastify.addHook("onReady", () => {
|
|
1810
1825
|
setWebSocketManager(fastify.websockets);
|
|
1811
1826
|
});
|
|
1827
|
+
fastify.addHook("onRequest", async (request) => {
|
|
1828
|
+
const [pathname] = request.url.split("?");
|
|
1829
|
+
const match = pathname.match(/^\/api\/([^/]+)(?:\/([^/]+))?/);
|
|
1830
|
+
initializeLogger(match?.[2] || "", request.id);
|
|
1831
|
+
});
|
|
1832
|
+
fastify.addHook("onResponse", async () => {
|
|
1833
|
+
initializeLogger("default", void 0);
|
|
1834
|
+
});
|
|
1812
1835
|
return fastify;
|
|
1813
1836
|
}
|
|
1814
1837
|
|