Skip to content
Snippets Groups Projects
Select Git revision
  • d2f37ebe4d4d87d1a8af30aa624f6134150e2360
  • master default protected
  • devel
  • hruska-feature-clients-api
  • malostik-#5066-deduplicate-idea-ids
  • warden-postgresql-port
  • hruska-feature-#6799-filter-keys
  • hruska-feature-5066-duplicateIdeaID
  • warden-client-3.0-beta3
  • warden-server-3.0-beta3
  • warden-client-2.2-final
  • warden-server-2.2-final
  • warden-client-3.0-beta2
  • warden-server-3.0-beta2
  • warden-client-2.2
  • warden-server-2.2-patch3
  • warden-client-3.0-beta1
  • warden-server-3.0-beta1
  • warden-server-2.2-patch1
  • warden-client-3.0-beta0
  • warden-server-3.0-beta0
  • warden-server-2.2
  • warden-server-2.1-patch1
  • warden-client-2.1
  • warden-server-2.1
  • warden-server-2.1-beta6
  • warden-server-2.1-beta5
  • warden-server-2.1-beta4
28 results

DB.pm

Blame
  • console-logger.ts 1.30 KiB
    /**
     * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author David Sehnal <david.sehnal@gmail.com>
     */
    
    export namespace ConsoleLogger {
        export function formatTime(t: number) {
            if (isNaN(t)) return 'n/a';
    
            let h = Math.floor(t / (60 * 60 * 1000)),
                m = Math.floor(t / (60 * 1000) % 60),
                s = Math.floor(t / 1000 % 60),
                ms = Math.floor(t % 1000).toString();
    
            while (ms.length < 3) ms = '0' + ms;
    
            if (h > 0) return `${h}h${m}m${s}.${ms}s`;
            if (m > 0) return `${m}m${s}.${ms}s`;
            if (s > 0) return `${s}.${ms}s`;
            return `${t.toFixed(0)}ms`;
        }
    
        export function log(tag: string, msg: string) {
            console.log(`[${tag}] ${msg}`);
        }
    
        export function logId(guid: string | String, tag: string, msg: string) {
            console.log(`[${guid}][${tag}] ${msg}`);
        }
    
        export function error(ctx: string, e: any) {
            console.error(`[Error] (${ctx}) ${e}`);
            if (e.stack) console.error(e.stack);
        }
    
        export function warn(ctx: string, e: any) {
            console.error(`[Warn] (${ctx}) ${e}`);
        }
    
        export function errorId(guid: string | String, e: any) {
            console.error(`[${guid}][Error] ${e}`);
            if (e.stack) console.error(e.stack);
        }
    }