import nconf , { Provider } from "nconf" ; import { WinstonLumberjackEngine } from "@fluidframework/server-services-utils" ; import { ILumberjackEngine , ILumberjackSchemaValidator , Lumberjack } from "@fluidframework/server-services-telemetry" ; /**
 * Helps to avoid package version mismatch issues with usage of global Lumberjack instance.
 * Configures the default behavior of the Winston and Lumberjack loggers based on the provided config.
 *
 * IMPORTANT: call this after `configureLogging` has been called, if calling both, so that Lumberjack is not
 * setup twice, which will throw an error. `configureLogging` does not do a safety check when setting up Lumberjack.
 */ export function configureHistorianLogging ( configOrPath ) { if ( ! Lumberjack . isSetupCompleted ( ) ) { const config = typeof configOrPath === "string" ? nconf . argv ( ) . env ( { separator : "__" , parseValues : true } ) . file ( configOrPath ) . use ( "memory" ) : configOrPath ; const lumberjackConfig = config . get ( "lumberjack" ) ; const engineList = lumberjackConfig && lumberjackConfig . engineList ? lumberjackConfig . engineList as ILumberjackEngine [ ] : [ new WinstonLumberjackEngine ( ) ] ; const schemaValidatorList = lumberjackConfig && lumberjackConfig . schemaValidator ? lumberjackConfig . schemaValidator as ILumberjackSchemaValidator [ ] : undefined ; Lumberjack . setup ( engineList , schemaValidatorList ) ; } }