Comparing version 1.1.18 to 1.1.21
@@ -1,2 +0,2 @@ | ||
/* Brolog version 1.1.18 */ | ||
/* Brolog version 1.1.21 */ | ||
(function (global, factory) { | ||
@@ -36,2 +36,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
constructor() { | ||
this.enableTimestamp = true; | ||
this.logLevel = LogLevel.info; | ||
@@ -116,12 +117,17 @@ this.prefixFilter = /.*/; // Match all by default | ||
const args = Array.prototype.slice.call(arguments, 3) || []; | ||
args.unshift(Brolog.timestamp() + ' ' + levelTitle + ' ' + prefix + ' ' + (message || '')); | ||
args.unshift(this.timestamp() + ' ' + levelTitle + ' ' + prefix + ' ' + (message || '')); | ||
// Use Reflect at: | ||
// https://www.keithcirkel.co.uk/metaprogramming-in-es6-part-2-reflect/ | ||
switch (levelTitle) { | ||
case 'ERR': | ||
console.error.apply(console, args); | ||
// console.error.apply(console, args) | ||
Reflect.apply(console.error, console, args); | ||
break; | ||
case 'WARN': | ||
console.warn.apply(console, args); | ||
// console.warn.apply(console, args) | ||
Reflect.apply(console.warn, console, args); | ||
break; | ||
case 'INFO': | ||
console.info.apply(console, args); | ||
// console.info.apply(console, args) | ||
Reflect.apply(console.info, console, args); | ||
break; | ||
@@ -131,3 +137,4 @@ default: | ||
case 'SILL': | ||
console.log.apply(console, args); | ||
// console.log.apply(console, args) | ||
Reflect.apply(console.log, console, args); | ||
} | ||
@@ -137,3 +144,4 @@ } | ||
const instance = Brolog.instance(); | ||
return instance.error.apply(instance, arguments); | ||
// return instance.error.apply(instance, arguments) | ||
return Reflect.apply(instance.error, instance, arguments); | ||
} | ||
@@ -146,7 +154,9 @@ error(prefix, ...args) { | ||
argList.unshift('ERR'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static warn(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.warn.apply(instance, arguments); | ||
// return instance.warn.apply(instance, arguments) | ||
return Reflect.apply(instance.warn, instance, arguments); | ||
} | ||
@@ -159,7 +169,9 @@ warn(prefix, ...args) { | ||
argList.unshift('WARN'); | ||
this.log.apply(this, argList); | ||
// return this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static info(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.info.apply(instance, arguments); | ||
// return instance.info.apply(instance, arguments) | ||
return Reflect.apply(instance.info, instance, arguments); | ||
} | ||
@@ -172,7 +184,9 @@ info(prefix, ...args) { | ||
argList.unshift('INFO'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static verbose(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.verbose.apply(instance, arguments); | ||
// return instance.verbose.apply(instance, arguments) | ||
return Reflect.apply(instance.verbose, instance, arguments); | ||
} | ||
@@ -185,7 +199,9 @@ verbose(prefix, ...args) { | ||
argList.unshift('VERB'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static silly(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.silly.apply(instance, arguments); | ||
// return instance.silly.apply(instance, arguments) | ||
return Reflect.apply(instance.silly, instance, arguments); | ||
} | ||
@@ -198,5 +214,13 @@ silly(prefix, ...args) { | ||
argList.unshift('SILL'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static timestamp() { | ||
timestamp(enable) { | ||
if (typeof enable === 'boolean') { | ||
this.enableTimestamp = enable; | ||
return; | ||
} | ||
if (!this.enableTimestamp) { | ||
return ''; | ||
} | ||
const date = new Date(); | ||
@@ -203,0 +227,0 @@ const hour = date.getHours(); |
@@ -1,2 +0,2 @@ | ||
/* Brolog version 1.1.18 */ | ||
/* Brolog version 1.1.21 */ | ||
(function (global, factory) { | ||
@@ -36,2 +36,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
function Brolog() { | ||
this.enableTimestamp = true; | ||
this.logLevel = LogLevel.info; | ||
@@ -116,12 +117,17 @@ this.prefixFilter = /.*/; // Match all by default | ||
var args = Array.prototype.slice.call(arguments, 3) || []; | ||
args.unshift(Brolog.timestamp() + ' ' + levelTitle + ' ' + prefix + ' ' + (message || '')); | ||
args.unshift(this.timestamp() + ' ' + levelTitle + ' ' + prefix + ' ' + (message || '')); | ||
// Use Reflect at: | ||
// https://www.keithcirkel.co.uk/metaprogramming-in-es6-part-2-reflect/ | ||
switch (levelTitle) { | ||
case 'ERR': | ||
console.error.apply(console, args); | ||
// console.error.apply(console, args) | ||
Reflect.apply(console.error, console, args); | ||
break; | ||
case 'WARN': | ||
console.warn.apply(console, args); | ||
// console.warn.apply(console, args) | ||
Reflect.apply(console.warn, console, args); | ||
break; | ||
case 'INFO': | ||
console.info.apply(console, args); | ||
// console.info.apply(console, args) | ||
Reflect.apply(console.info, console, args); | ||
break; | ||
@@ -131,3 +137,4 @@ default: | ||
case 'SILL': | ||
console.log.apply(console, args); | ||
// console.log.apply(console, args) | ||
Reflect.apply(console.log, console, args); | ||
} | ||
@@ -141,3 +148,4 @@ }; | ||
var instance = Brolog.instance(); | ||
return instance.error.apply(instance, arguments); | ||
// return instance.error.apply(instance, arguments) | ||
return Reflect.apply(instance.error, instance, arguments); | ||
}; | ||
@@ -154,3 +162,4 @@ Brolog.prototype.error = function (prefix) { | ||
argList.unshift('ERR'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
}; | ||
@@ -163,3 +172,4 @@ Brolog.warn = function (prefix) { | ||
var instance = Brolog.instance(); | ||
return instance.warn.apply(instance, arguments); | ||
// return instance.warn.apply(instance, arguments) | ||
return Reflect.apply(instance.warn, instance, arguments); | ||
}; | ||
@@ -176,3 +186,4 @@ Brolog.prototype.warn = function (prefix) { | ||
argList.unshift('WARN'); | ||
this.log.apply(this, argList); | ||
// return this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
}; | ||
@@ -185,3 +196,4 @@ Brolog.info = function (prefix) { | ||
var instance = Brolog.instance(); | ||
return instance.info.apply(instance, arguments); | ||
// return instance.info.apply(instance, arguments) | ||
return Reflect.apply(instance.info, instance, arguments); | ||
}; | ||
@@ -198,3 +210,4 @@ Brolog.prototype.info = function (prefix) { | ||
argList.unshift('INFO'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
}; | ||
@@ -207,3 +220,4 @@ Brolog.verbose = function (prefix) { | ||
var instance = Brolog.instance(); | ||
return instance.verbose.apply(instance, arguments); | ||
// return instance.verbose.apply(instance, arguments) | ||
return Reflect.apply(instance.verbose, instance, arguments); | ||
}; | ||
@@ -220,3 +234,4 @@ Brolog.prototype.verbose = function (prefix) { | ||
argList.unshift('VERB'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
}; | ||
@@ -229,3 +244,4 @@ Brolog.silly = function (prefix) { | ||
var instance = Brolog.instance(); | ||
return instance.silly.apply(instance, arguments); | ||
// return instance.silly.apply(instance, arguments) | ||
return Reflect.apply(instance.silly, instance, arguments); | ||
}; | ||
@@ -242,5 +258,13 @@ Brolog.prototype.silly = function (prefix) { | ||
argList.unshift('SILL'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
}; | ||
Brolog.timestamp = function () { | ||
Brolog.prototype.timestamp = function (enable) { | ||
if (typeof enable === 'boolean') { | ||
this.enableTimestamp = enable; | ||
return; | ||
} | ||
if (!this.enableTimestamp) { | ||
return ''; | ||
} | ||
var date = new Date(); | ||
@@ -247,0 +271,0 @@ var hour = date.getHours(); |
@@ -22,2 +22,3 @@ /*! | ||
export declare class Brolog implements Loggable { | ||
private enableTimestamp; | ||
private logLevel; | ||
@@ -46,3 +47,4 @@ private prefixFilter; | ||
silly(prefix: string, ...args: any[]): void; | ||
static timestamp(): string; | ||
timestamp(enable: boolean): void; | ||
timestamp(): string; | ||
} | ||
@@ -49,0 +51,0 @@ export declare const globalBrolog: Brolog; |
@@ -29,2 +29,3 @@ /*! | ||
constructor() { | ||
this.enableTimestamp = true; | ||
this.logLevel = LogLevel.info; | ||
@@ -109,12 +110,17 @@ this.prefixFilter = /.*/; // Match all by default | ||
const args = Array.prototype.slice.call(arguments, 3) || []; | ||
args.unshift(Brolog.timestamp() + ' ' + levelTitle + ' ' + prefix + ' ' + (message || '')); | ||
args.unshift(this.timestamp() + ' ' + levelTitle + ' ' + prefix + ' ' + (message || '')); | ||
// Use Reflect at: | ||
// https://www.keithcirkel.co.uk/metaprogramming-in-es6-part-2-reflect/ | ||
switch (levelTitle) { | ||
case 'ERR': | ||
console.error.apply(console, args); | ||
// console.error.apply(console, args) | ||
Reflect.apply(console.error, console, args); | ||
break; | ||
case 'WARN': | ||
console.warn.apply(console, args); | ||
// console.warn.apply(console, args) | ||
Reflect.apply(console.warn, console, args); | ||
break; | ||
case 'INFO': | ||
console.info.apply(console, args); | ||
// console.info.apply(console, args) | ||
Reflect.apply(console.info, console, args); | ||
break; | ||
@@ -124,3 +130,4 @@ default: | ||
case 'SILL': | ||
console.log.apply(console, args); | ||
// console.log.apply(console, args) | ||
Reflect.apply(console.log, console, args); | ||
} | ||
@@ -130,3 +137,4 @@ } | ||
const instance = Brolog.instance(); | ||
return instance.error.apply(instance, arguments); | ||
// return instance.error.apply(instance, arguments) | ||
return Reflect.apply(instance.error, instance, arguments); | ||
} | ||
@@ -139,7 +147,9 @@ error(prefix, ...args) { | ||
argList.unshift('ERR'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static warn(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.warn.apply(instance, arguments); | ||
// return instance.warn.apply(instance, arguments) | ||
return Reflect.apply(instance.warn, instance, arguments); | ||
} | ||
@@ -152,7 +162,9 @@ warn(prefix, ...args) { | ||
argList.unshift('WARN'); | ||
this.log.apply(this, argList); | ||
// return this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static info(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.info.apply(instance, arguments); | ||
// return instance.info.apply(instance, arguments) | ||
return Reflect.apply(instance.info, instance, arguments); | ||
} | ||
@@ -165,7 +177,9 @@ info(prefix, ...args) { | ||
argList.unshift('INFO'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static verbose(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.verbose.apply(instance, arguments); | ||
// return instance.verbose.apply(instance, arguments) | ||
return Reflect.apply(instance.verbose, instance, arguments); | ||
} | ||
@@ -178,7 +192,9 @@ verbose(prefix, ...args) { | ||
argList.unshift('VERB'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static silly(prefix, ...args) { | ||
const instance = Brolog.instance(); | ||
return instance.silly.apply(instance, arguments); | ||
// return instance.silly.apply(instance, arguments) | ||
return Reflect.apply(instance.silly, instance, arguments); | ||
} | ||
@@ -191,5 +207,13 @@ silly(prefix, ...args) { | ||
argList.unshift('SILL'); | ||
this.log.apply(this, argList); | ||
// this.log.apply(this, argList) | ||
return Reflect.apply(this.log, this, argList); | ||
} | ||
static timestamp() { | ||
timestamp(enable) { | ||
if (typeof enable === 'boolean') { | ||
this.enableTimestamp = enable; | ||
return; | ||
} | ||
if (!this.enableTimestamp) { | ||
return ''; | ||
} | ||
const date = new Date(); | ||
@@ -196,0 +220,0 @@ const hour = date.getHours(); |
{ | ||
"name": "brolog", | ||
"version": "1.1.18", | ||
"version": "1.1.21", | ||
"description": "Npmlog like logger for Browser", | ||
@@ -9,12 +9,13 @@ "main": "bundles/brolog.umd.js", | ||
"clean": "rm -fr dist/* bundles/*", | ||
"dist": "npm run clean && npm run build && npm run rollup && npm run es6to5", | ||
"patch": "echo 'DEPRECATED, use rollup.conf by set moduleName to windows.' && patch < patch/umd.patch bundles/brolog.umd.js", | ||
"dist": "npm run clean && npm run build && npm run rollup && npm run dist:es6to5", | ||
"dist:es6to5": "tsc --out ./bundles/brolog.umd.js --target es5 --allowJs bundles/brolog.es6.umd.js --lib es6,dom", | ||
"dist:patch": "echo 'DEPRECATED, use rollup.conf by set moduleName to windows.' && patch < patch/umd.patch bundles/brolog.umd.js", | ||
"build": "tsc --module es6", | ||
"e2e": "test/protractor.sh", | ||
"lint": "npm run tslint", | ||
"lint": "npm run lint:ts", | ||
"rollup": "rollup -c", | ||
"es6to5": "tsc --out ./bundles/brolog.umd.js --target es5 --allowJs bundles/brolog.es6.umd.js --lib es6,dom", | ||
"tslint": "tslint src/**/*.ts && tsc --noEmit", | ||
"test": "npm run dist && npm run unit && npm run e2e", | ||
"unit": "tap -R tap test/unit/**/*.spec.ts" | ||
"lint:ts": "tslint src/**/*.ts && tsc --noEmit", | ||
"test": "npm run dist && npm run test:unit && npm run test:e2e", | ||
"test:e2e": "test/protractor.sh", | ||
"test:npm": "export TMPDIR=/tmp/brolog-npm.$$ && mkdir $TMPDIR && npm pack && mv brolog-*.*.*.tgz $TMPDIR && cp example/npm-like-logger.js $TMPDIR && cd $TMPDIR && npm init -y && npm install brolog-*.*.*.tgz && node npm-like-logger.js", | ||
"test:unit": "tap -R tap test/unit/**/*.spec.ts" | ||
}, | ||
@@ -21,0 +22,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59910
794