From 2b8923ef88d8bb89ca322157315dd33ce9c4210a Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 13 Nov 2024 11:06:54 -0600 Subject: [PATCH] Update logging options --- sdks/node-sdk/src/Client.ts | 17 ++++++++++++++--- sdks/node-sdk/src/index.ts | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sdks/node-sdk/src/Client.ts b/sdks/node-sdk/src/Client.ts index 1736c7b8f..a1eb69562 100644 --- a/sdks/node-sdk/src/Client.ts +++ b/sdks/node-sdk/src/Client.ts @@ -15,8 +15,10 @@ import { generateInboxId, getInboxIdForAddress, GroupMessageKind, + Level, type Consent, type ConsentEntityType, + type LogOptions, type Message, type Client as NodeClient, type SignatureRequestType, @@ -69,9 +71,13 @@ export type OtherOptions = { */ requestHistorySync?: string; /** - * Optionally set the logging level (default: 'off') + * Enable structured JSON logging */ - logging?: "debug" | "info" | "warn" | "error" | "off"; + structuredLogging?: boolean; + /** + * Logging level + */ + loggingLevel?: Level; }; export type ClientOptions = NetworkOptions & @@ -106,6 +112,11 @@ export class Client { (await getInboxIdForAddress(host, isSecure, accountAddress)) || generateInboxId(accountAddress); + const logOptions: LogOptions = { + structured: options?.structuredLogging ?? false, + level: options?.loggingLevel ?? Level.off, + }; + return new Client( await createClient( host, @@ -115,7 +126,7 @@ export class Client { accountAddress, encryptionKey, options?.requestHistorySync, - options?.logging ?? "off", + logOptions, ), [new GroupUpdatedCodec(), new TextCodec(), ...(options?.codecs ?? [])], ); diff --git a/sdks/node-sdk/src/index.ts b/sdks/node-sdk/src/index.ts index 51eb404c4..aef488ac5 100644 --- a/sdks/node-sdk/src/index.ts +++ b/sdks/node-sdk/src/index.ts @@ -19,6 +19,7 @@ export type { Installation, ListConversationsOptions, ListMessagesOptions, + LogOptions, Message, PermissionPolicySet, } from "@xmtp/node-bindings"; @@ -33,6 +34,7 @@ export { GroupMetadata, GroupPermissions, GroupPermissionsOptions, + Level, PermissionLevel, PermissionPolicy, PermissionUpdateType,