UNPKG

@mjcctech/meteor-desktop

Version:

Build a Meteor's desktop client with hot code push.

65 lines (54 loc) 1.22 kB
"use strict";module.export({default:()=>Log});/* eslint-disable no-console */ /* 0.OFF 1.INFO 2.WARN 3.ERROR 4.TRACE 5.DEBUG 6.ALL */ class Log { constructor(prefix) { this.prefix = prefix; } static level() { return process.env.MD_LOG_LEVEL || 'ALL'; } static slice(args) { return Array.prototype.slice.call(args, 0); } log(type, args) { console.log.apply(null, [`${type} ${this.prefix}: `].concat(Log.slice(args))); } info(...args) { if (/INFO|ALL/i.test(Log.level())) { this.log('INFO', args); } } warn(...args) { if (/WARN|ALL/i.test(Log.level())) { this.log('WARN', args); } } error(...args) { if (/ERROR|ALL/i.test(Log.level())) { this.log('ERROR', args); } } debug(...args) { if (/DEBUG|ALL/i.test(Log.level())) { this.log('DEBUG', args); } } verbose(...args) { if (/VERBOSE|ALL/i.test(Log.level())) { this.log('VERBOSE', args); } } trace(...args) { if (/TRACE|ALL/i.test(Log.level())) { this.log('TRACE', args); } } }