grpc-js: Include library version and PID in all trace logs

This commit is contained in:
Michael Lumish 2023-10-16 17:06:32 -07:00
parent 065ac2fef6
commit 0f8ebbdd17
3 changed files with 5 additions and 10 deletions

View File

@ -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
- NONE - won't log any

View File

@ -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();

View File

@ -16,6 +16,9 @@
*/
import { LogVerbosity } from './constants';
import { pid } from 'process';
const clientVersion = require('../../package.json').version;
const DEFAULT_LOGGER: Partial<Console> = {
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);
}
}