From 57c2bb658f0e41a84873306cca0cad52ac2fb096 Mon Sep 17 00:00:00 2001 From: ryjiang Date: Mon, 25 Nov 2024 14:21:50 +0800 Subject: [PATCH] support log prefix Signed-off-by: ryjiang --- milvus/MilvusClient.ts | 3 +++ milvus/types/Client.ts | 2 ++ test/grpc/Basic.spec.ts | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/milvus/MilvusClient.ts b/milvus/MilvusClient.ts index 8003b4aa..f1cdea64 100644 --- a/milvus/MilvusClient.ts +++ b/milvus/MilvusClient.ts @@ -57,6 +57,9 @@ export class MilvusClient extends GRPCClient { if (this.config.logLevel) { logger.level = this.config.logLevel; } + if (this.config.logPrefix) { + logger.defaultMeta = { service: this.config.logPrefix }; + } logger.debug( `new client initialized, version: ${MilvusClient.sdkInfo.version} ` diff --git a/milvus/types/Client.ts b/milvus/types/Client.ts index bf7a181a..abf23647 100644 --- a/milvus/types/Client.ts +++ b/milvus/types/Client.ts @@ -36,6 +36,8 @@ export interface ClientConfig { database?: string; // log level logLevel?: string; + // log prefix + logPrefix?: string; tls?: { // root certificate file path, it can be a CA PEM (Certificate Authority PEM) or Server PEM (Server Certificate PEM): diff --git a/test/grpc/Basic.spec.ts b/test/grpc/Basic.spec.ts index e88f55f2..13e803f0 100644 --- a/test/grpc/Basic.spec.ts +++ b/test/grpc/Basic.spec.ts @@ -1,7 +1,11 @@ import { MilvusClient, ErrorCode, DataType } from '../../milvus'; import { IP, GENERATE_NAME, generateInsertData } from '../tools'; -const milvusClient = new MilvusClient({ address: IP, logLevel: 'info' }); +const milvusClient = new MilvusClient({ + address: IP, + logLevel: 'debug', + logPrefix: 'Basic API', +}); const COLLECTION_NAME = GENERATE_NAME(); const schema = [ {