import { Observable } from 'rxjs' ; import { tap } from 'rxjs/operators' ; export enum RxJsLoggingLevel { TRACE , DEBUG , INFO , ERROR } let rxjsLoggingLevel = RxJsLoggingLevel . INFO ; export function setRxJsLoggingLevel ( level ) { rxjsLoggingLevel = level ; } export const debug = ( level , message ) => ( source ) => source . pipe ( tap ( val => { if ( level >= rxjsLoggingLevel ) { console . log ( message + ': ' , val ) ; } } ) ) ;