Skip to content

Commit cb2cdda

Browse files
committed
🧑‍💻 improve log format for gcloud
1 parent 05c60fc commit cb2cdda

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/util/logger.util.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,22 @@ const logger = (
5858
// eslint-disable-next-line no-console
5959
const anonymizedApiKey = apiKey ? anonymizeKey(apiKey) : undefined;
6060

61-
logFn(
62-
constructLogMessage(
63-
anonymizedApiKey ? `[${anonymizedApiKey}]` : undefined,
64-
`[${source}]`,
65-
message
66-
),
67-
...args
61+
const formatedMessage = constructLogMessage(
62+
anonymizedApiKey ? `[${anonymizedApiKey}]` : undefined,
63+
`[${source}]`,
64+
message
6865
);
66+
67+
if (process.env.NODE_ENV == "development") {
68+
logFn(formatedMessage, ...args);
69+
} else {
70+
logFn(
71+
JSON.stringify({
72+
message: formatedMessage,
73+
data: args,
74+
})
75+
);
76+
}
6977
};
7078

7179
const constructLogMessage = (...args: unknown[]): string =>

0 commit comments

Comments
 (0)