From 0f8ebbdd1786ad134ea17af2615e6070ee961bc1 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Mon, 16 Oct 2023 17:06:32 -0700 Subject: [PATCH] grpc-js: Include library version and PID in all trace logs --- doc/environment_variables.md | 3 +-- packages/grpc-js/src/index.ts | 7 ------- packages/grpc-js/src/logging.ts | 5 ++++- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/doc/environment_variables.md b/doc/environment_variables.md index 70b32e71..1b5ad26a 100644 --- a/doc/environment_variables.md +++ b/doc/environment_variables.md @@ -42,7 +42,6 @@ can be set. - `subchannel_internals` - Traces HTTP/2 session state. Includes per-call logs. - `channel_stacktrace` - Traces channel construction events with stack traces. - `keepalive` - Traces gRPC keepalive pings - - `index` - Traces module loading - `outlier_detection` - Traces outlier detection events The following tracers are added by the `@grpc/grpc-js-xds` library: @@ -62,4 +61,4 @@ can be set. - DEBUG - log all gRPC messages - INFO - log INFO and ERROR message - ERROR - log only errors (default) - - NONE - won't log any \ No newline at end of file + - NONE - won't log any diff --git a/packages/grpc-js/src/index.ts b/packages/grpc-js/src/index.ts index adacae08..28fc776c 100644 --- a/packages/grpc-js/src/index.ts +++ b/packages/grpc-js/src/index.ts @@ -273,14 +273,7 @@ import * as load_balancer_outlier_detection from './load-balancer-outlier-detect import * as channelz from './channelz'; import { Deadline } from './deadline'; -const clientVersion = require('../../package.json').version; - (() => { - logging.trace( - LogVerbosity.DEBUG, - 'index', - 'Loading @grpc/grpc-js version ' + clientVersion - ); resolver_dns.setup(); resolver_uds.setup(); resolver_ip.setup(); diff --git a/packages/grpc-js/src/logging.ts b/packages/grpc-js/src/logging.ts index 83438ef7..e1b396ff 100644 --- a/packages/grpc-js/src/logging.ts +++ b/packages/grpc-js/src/logging.ts @@ -16,6 +16,9 @@ */ import { LogVerbosity } from './constants'; +import { pid } from 'process'; + +const clientVersion = require('../../package.json').version; const DEFAULT_LOGGER: Partial = { error: (message?: any, ...optionalParams: any[]) => { @@ -109,7 +112,7 @@ export function trace( text: string ): void { if (isTracerEnabled(tracer)) { - log(severity, new Date().toISOString() + ' | ' + tracer + ' | ' + text); + log(severity, new Date().toISOString() + ' | v' + clientVersion + ' ' + pid + ' | ' + tracer + ' | ' + text); } }