import { Options } from "yargs" ; import { LogLevel , LogLevels } from "@chainsafe/lodestar-utils" ; import { defaultOptions , IBeaconNodeOptions } from "@chainsafe/lodestar" ; import { ICliCommandOptions , ObjectKeys } from "../../util" ; export type ILoggerArgs = Record < string , unknown > ; const getArgKey = ( logModule ) : keyof ILoggerArgs => `logger.${ logModule }.level` as keyof ILoggerArgs ; export function parseArgs ( args ) { return ObjectKeys ( defaultOptions . logger ) . reduce ( ( options , logModule ) => { const level = args [ getArgKey ( logModule ) ] ; if ( level ) options [ logModule ] = { level : LogLevel [ level as LogLevel ] } ; return options ; } , { } ) ; } /**
 * Generates an option for each module in defaultOptions.logger
 * chain, db, eth1, etc
 */ export const options = ObjectKeys ( defaultOptions . logger ) . reduce ( ( options , logModule ) : Record < string , Options > => ( { ... options , [ getArgKey ( logModule ) ] : { hidden : true , type : "string" , choices : LogLevels , description : `Logging verbosity level for ${ logModule }` , defaultDescription : ( defaultOptions . logger [ logModule ] ?? { } ) . level , group : "log" , } , } ) , { } ) ;