import ApplicationInsights = require ( "applicationinsights" ) ; import { channel , IStandardEvent } from "diagnostic-channel" ; import { bunyan } from "diagnostic-channel-publishers" ; const bunyanToAILevelMap = { } ; bunyanToAILevelMap [ 10 ] = ApplicationInsights . Contracts . SeverityLevel . Verbose ; bunyanToAILevelMap [ 20 ] = ApplicationInsights . Contracts . SeverityLevel . Verbose ; bunyanToAILevelMap [ 30 ] = ApplicationInsights . Contracts . SeverityLevel . Information ; bunyanToAILevelMap [ 40 ] = ApplicationInsights . Contracts . SeverityLevel . Warning ; bunyanToAILevelMap [ 50 ] = ApplicationInsights . Contracts . SeverityLevel . Error ; bunyanToAILevelMap [ 60 ] = ApplicationInsights . Contracts . SeverityLevel . Critical ; export const subscriber = ( event ) => { if ( ApplicationInsights . defaultClient ) { const AIlevel = bunyanToAILevelMap [ event . data . level ] ; ApplicationInsights . defaultClient . trackTrace ( { message : event . data . result , severity : AIlevel } ) ; } } ; channel . subscribe < bunyan . IBunyanData > ( "bunyan" , subscriber ) ;