Skip to content

Commit 057d1f7

Browse files
authored
Merge pull request #275 from axiomhq/gabrielelpidio/fix-default-formatter-fields
fix: default formatter fields
2 parents 5d9eee1 + a320852 commit 057d1f7

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/logging/src/default-formatters.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { isEdgeRuntime } from 'src/runtime';
55
interface BasePlatform {
66
environment?: string;
77
region?: string;
8-
// source: source, @TODO
8+
source?: string;
99
}
1010

1111
type VercelLogEvent = LogEvent & {
@@ -42,11 +42,16 @@ export const injectPlatform: Formatter = (logEvent): PlatformLogEvent => {
4242

4343
if (isVercel) {
4444
const vercelLogEvent = logEvent as VercelLogEvent;
45-
vercelLogEvent.vercel.environment = environment;
46-
vercelLogEvent.vercel.region = process.env.VERCEL_REGION;
47-
vercelLogEvent.vercel.deploymentId = process.env.VERCEL_DEPLOYMENT_ID;
48-
vercelLogEvent.vercel.deploymentUrl = process.env.NEXT_PUBLIC_VERCEL_URL;
49-
vercelLogEvent.vercel.project = process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL;
45+
46+
vercelLogEvent.vercel = {
47+
environment: process.env.VERCEL_ENV ?? environment,
48+
region: process.env.VERCEL_REGION,
49+
deploymentId: process.env.VERCEL_DEPLOYMENT_ID,
50+
deploymentUrl: process.env.NEXT_PUBLIC_VERCEL_URL,
51+
project: process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL,
52+
source: logEvent.source,
53+
};
54+
5055
vercelLogEvent.git = {
5156
commit: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,
5257
repo: process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG,
@@ -59,12 +64,14 @@ export const injectPlatform: Formatter = (logEvent): PlatformLogEvent => {
5964
if (isNetlify) {
6065
const netlifyLogEvent = logEvent as NetlifyLogEvent;
6166
netlifyLogEvent.netlify = {
67+
environment: environment,
6268
region: isEdgeRuntime ? process.env.DENO_REGION : process.env.AWS_REGION,
6369
siteId: process.env.SITE_ID,
6470
buildId: process.env.BUILD_ID,
6571
context: process.env.CONTEXT,
6672
deploymentUrl: process.env.DEPLOYMENT_URL,
6773
deploymentId: isEdgeRuntime ? process.env.DENO_DEPLOYMENT_ID : process.env.NETLIFY_DEPLOYMENT_ID,
74+
source: logEvent.source,
6875
};
6976

7077
return netlifyLogEvent;
@@ -74,7 +81,7 @@ export const injectPlatform: Formatter = (logEvent): PlatformLogEvent => {
7481
genericLogEvent.platform = {
7582
environment: environment,
7683
region: region,
77-
// source: source, @TODO
84+
source: logEvent.source,
7885
};
7986

8087
return genericLogEvent;

packages/logging/src/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface LogEvent extends Record<string, any> {
2929
'@app': {
3030
[key: FrameworkIdentifier['name']]: FrameworkIdentifier['version'];
3131
};
32+
source: string;
3233
}
3334
export const LogLevelValue = {
3435
debug: 0,

0 commit comments

Comments
 (0)