11import yargs from 'yargs' ;
22import { hideBin } from 'yargs/helpers' ;
33import { startServer } from '../grpc/server.js' ;
4+ import { LogFormat , LogLevel , createLogger } from '../logger/logger.js' ;
45
56const NETWORK_CHOICES = [ 'tcp' , 'tcp4' , 'tcp6' , 'unix' , 'unixpacket' ] as const ;
6- const LOG_LEVEL_CHOICES = [ 'trace' , 'debug' , 'info' , 'warn' , 'error' ] as const ;
7- const LOG_FORMAT_CHOICES = [ 'json' , 'text' ] as const ;
7+
88const TELEMETRY_LEVEL_CHOICES = [ 'none' , 'errors' , 'stats' , 'all' ] as const ;
99
1010export type ServeArguments = {
1111 address : string ;
1212 network : ( typeof NETWORK_CHOICES ) [ number ] ;
13- logLevel : ( typeof LOG_LEVEL_CHOICES ) [ number ] ;
14- logFormat : ( typeof LOG_FORMAT_CHOICES ) [ number ] ;
13+ logLevel : LogLevel ;
14+ logFormat : LogFormat ;
1515 sentry : boolean ;
1616 otelEndpoint : string ;
1717 otelEndpointInsecure : boolean ;
@@ -24,8 +24,9 @@ export const serve = yargs(hideBin(process.argv))
2424 'start plugin gRPC server' ,
2525 ( ) => { } ,
2626 ( { address, network, logLevel, logFormat, sentry : sentry , otelEndpoint, telemetryLevel } : ServeArguments ) => {
27- console . log ( { address, network, logLevel, logFormat, sentry, otelEndpoint, telemetryLevel } ) ;
28- startServer ( address ) ;
27+ const logger = createLogger ( logLevel , logFormat ) ;
28+ logger . info ( JSON . stringify ( { address, network, logLevel, logFormat, sentry, otelEndpoint, telemetryLevel } ) ) ;
29+ startServer ( logger , address ) ;
2930 } ,
3031 )
3132 . options ( {
@@ -45,14 +46,14 @@ export const serve = yargs(hideBin(process.argv))
4546 'log-level' : {
4647 alias : 'l' ,
4748 type : 'string' ,
48- choices : LOG_LEVEL_CHOICES ,
49+ choices : Object . values ( LogLevel ) ,
4950 description : 'log level' ,
5051 default : 'info' ,
5152 } ,
5253 'log-format' : {
5354 alias : 'f' ,
5455 type : 'string' ,
55- choices : LOG_FORMAT_CHOICES ,
56+ choices : Object . values ( LogFormat ) ,
5657 description : 'log format' ,
5758 default : 'text' ,
5859 } ,
0 commit comments