Skip to content

Commit

Permalink
for vercel, ignore platform object
Browse files Browse the repository at this point in the history
  • Loading branch information
schehata committed Sep 28, 2022
1 parent 067ab58 commit 8712d98
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/logger.ts
Expand Up @@ -11,6 +11,7 @@ interface LogEvent {
_time: string;
request?: RequestReport;
platform?: PlatformInfo;
vercel?: PlatformInfo;
}

export interface RequestReport {
Expand Down Expand Up @@ -71,17 +72,31 @@ export class Logger {
logEvent.fields = args;
}

// logEvent.vercel = {
logEvent.platform = {
environment: config.getEnvironment(),
region: config.getRegion(),
source: this.source,
provider: config.provider,
};

if (config.provider != 'vercel') {
logEvent.vercel = {
environment: config.getEnvironment(),
region: config.getRegion(),
source: this.source,
provider: config.provider,
};
} else {
logEvent.platform = {
environment: config.getEnvironment(),
region: config.getRegion(),
source: this.source,
provider: config.provider,
};
}


if (this.req != null) {
logEvent.request = this.req;
logEvent.platform.route = this.req.path;
if (logEvent.platform) {
logEvent.platform.route = this.req.path;
} else if (logEvent.vercel) {
logEvent.vercel.route = this.req.path;
}
}

this.logEvents.push(logEvent);
Expand Down

0 comments on commit 8712d98

Please sign in to comment.