import { LogLevel } from '@amplitude/types' ; import { getGlobalAmplitudeNamespace } from './misc' ; const globalNamespace = getGlobalAmplitudeNamespace ( ) ; /** Prefix for logging strings */ const PREFIX = 'Amplitude Logger ' ; /** JSDoc */ class Logger { /** JSDoc */ private _logLevel : LogLevel ; /** JSDoc */ public constructor ( ) { this . _logLevel = 0 ; } /** JSDoc */ public disable ( ) { this . _logLevel = 0 ; } /** JSDoc */ public enable ( logLevel = LogLevel . Warn ) { this . _logLevel = logLevel ; } /** JSDoc */ public log ( ... args ) { if ( this . _logLevel < LogLevel . Verbose ) { return ; } global . console . log ( `${ PREFIX }[Log]: ${ args . join ( ' ' ) }` ) ; } /** JSDoc */ public warn ( ... args ) { if ( this . _logLevel < LogLevel . Warn ) { return ; } global . console . warn ( `${ PREFIX }[Warn]: ${ args . join ( ' ' ) }` ) ; } /** JSDoc */ public error ( ... args ) { if ( this . _logLevel < LogLevel . Error ) { return ; } global . console . error ( `${ PREFIX }[Error]: ${ args . join ( ' ' ) }` ) ; } } let logger = globalNamespace . logger as Logger ; if ( logger === undefined ) { logger = new Logger ( ) ; globalNamespace . logger = logger ; } export { logger } ;