Skip to content
Snippets Groups Projects
duration.ts 475 B
Newer Older
  • Learn to ignore specific revisions
  • Bastien DUMONT's avatar
    Bastien DUMONT committed
    import logApp from './logger'
    
    /**
     * Logs the time spend and add "in xx ms"
     * @param {string} scope string Migration | Initialization | ...
     * @param startTime number raw duration in ms
    
     * @description [Scope] Finished in XXX ms
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
     * @example
     * logDuration("[Migration] Finished", 764745674); // [Migration] Finished in 685 ms
     */
    export function logDuration(scope: string, startTime: number) {
      logApp.info(`${scope} in ${Math.round(performance.now() - startTime)} ms`)
    }