Skip to content
Snippets Groups Projects
Select Git revision
  • a04ed8135db57ffe2e507cd77e35b5ca12b6eb3d
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

grid-lookup.ts

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);
        }
    }