Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/api",
"version": "7.2.2",
"version": "7.2.3-beta.0",
"description": "VTEX I/O API client",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
36 changes: 25 additions & 11 deletions src/service/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ export class Logger {
const inflatedLog = {
__VTEX_IO_LOG: true,
level,
[AttributeKeys.VTEX_IO_APP_ID]: app,
[AttributeKeys.VTEX_ACCOUNT_NAME]: this.account,
[AttributeKeys.VTEX_IO_WORKSPACE_NAME]: this.workspace,
[AttributeKeys.VTEX_IO_WORKSPACE_TYPE]: this.production ? 'production' : 'development',
[AttributeKeys.VTEX_IO_APP_AUTHOR_TYPE]: APP.IS_THIRD_PARTY() ? '3p' : '1p',
app,
account: this.account,
workspace: this.workspace,
production: this.production,
operationId: this.operationId,
requestId: this.requestId,
data,
Expand All @@ -101,30 +100,45 @@ export class Logger {
});
}

console.log(JSON.stringify(inflatedLog))

const diagnosticsLog = {
__VTEX_IO_LOG: true,
level,
[AttributeKeys.VTEX_IO_APP_ID]: app,
[AttributeKeys.VTEX_ACCOUNT_NAME]: this.account,
[AttributeKeys.VTEX_IO_WORKSPACE_NAME]: this.workspace,
[AttributeKeys.VTEX_IO_WORKSPACE_TYPE]: this.production ? 'production' : 'development',
[AttributeKeys.VTEX_IO_APP_AUTHOR_TYPE]: APP.IS_THIRD_PARTY() ? '3p' : '1p',
operationId: this.operationId,
requestId: this.requestId,
data,
... (this.tracingState?.isTraceSampled ? { traceId: this.tracingState.traceId } : null),
}

if (this.logClient) {
try {
let logMessage = typeof data === 'string' ? data : JSON.stringify(data)
switch (level) {
case LogLevel.Debug:
this.logClient.debug(logMessage, inflatedLog);
this.logClient.debug(logMessage, diagnosticsLog);
break;
case LogLevel.Info:
this.logClient.info(logMessage, inflatedLog);
this.logClient.info(logMessage, diagnosticsLog);
break;
case LogLevel.Warn:
this.logClient.warn(logMessage, inflatedLog);
this.logClient.warn(logMessage, diagnosticsLog);
break;
case LogLevel.Error:
this.logClient.error(logMessage, inflatedLog);
this.logClient.error(logMessage, diagnosticsLog);
break;
default:
this.logClient.info(logMessage, inflatedLog);
this.logClient.info(logMessage, diagnosticsLog);
}
} catch (e) {
console.error('Error using diagnostics client for logging:', e);
}
}

console.log(JSON.stringify(inflatedLog))
}
}
Loading