You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mad-logs

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mad-logs - npm Package Compare versions

Comparing version

to
11.0.0

37

CHANGELOG.md

@@ -0,1 +1,37 @@

11.0.0 [HUGE BREAKING CHANGES]
==============================
Default export now proxies to shared module - build log with:
import {logFactory, Styles} from 'mad-logs/lib/shared';
const log = logFactory(`input-util-components.tsx`, Styles.angryBird);
...instead of:
import {logFactory, madLogMarkers} from 'mad-logs';
const log = logFactory()(`input-util-components.tsx`, madLogMarkers.angryBird);
Imports no longer available:
* `madLogMarkers` (replaced with `Styles`, but it works differently)
* `LogOpts`
* `AppConf`
* `MadLog` (replaced with `Log` e.g. `import {Log} from 'mad-logs';`)
* `logValues`
* `buildFileTag` (however, node variant still has it, for now)
Shared module exports `LogLevels` type
Total removal of original non-isomorphic mad-log module
Styles (shared):
* Remove braces from almost all Node log outputs
* Style `lucky` background colour changed to yellow
* New fountain style
Internal:
* Slightly cleaner tests
* Expanded docs
* REPL moved to script dir
* Cleaner code throughout
----------------------------------------------------------------------------------------------------
10.3.6

@@ -178,2 +214,3 @@ ======

----------------------------------------------------------------------------------------------------
9.1.2

@@ -180,0 +217,0 @@ =====

57

lib/index.d.ts

@@ -1,56 +0,1 @@

import { logMarkers } from './src/theming';
/**
* Provide deprecation warning if buildFileTag used in the browser
*/
export declare const buildFileTag: (filenm: string, clrize?: number | Function, rpadLen?: number) => string;
/**************************************** TYPE DEFINITIONS ****************************************/
export interface AppConf {
logLevel: keyof MadLog;
}
export interface LogOpts {
tagPrefix: string;
tagSuffix: string;
style: string;
}
export interface MadLog {
<T>(...strs: any[]): T;
silly: <T>(...args: Array<(string | any)>) => T;
verbose: <T>(...args: Array<(string | any)>) => T;
debug: <T>(...args: Array<(string | any)>) => T;
info: <T>(...args: Array<(string | any)>) => T;
warn: <T>(...args: Array<(string | any)>) => T;
error: <T>(...args: Array<(string | any)>) => T;
wtf: <T>(...args: Array<(string | any)>) => T;
}
/**
* Defines the available log levels in the application
*/
export declare const logValues: {
silly: number;
verbose: number;
debug: number;
info: number;
warn: number;
error: number;
wtf: number;
};
/**
* Export type containing all usable log levels
*/
export declare type LogLevels = keyof typeof logValues;
/************************************ MAIN LOG OBJECT FACTORY *************************************/
/**
* Build 'logger' object for reuse throughout any module it's constructed in
* Strings passed to factory appear on the left of all logs emitted by functions in the returned
* object, easing identification (visually & by search) of logs emitted in a specific file/module
*
* @param {string} filename Name of the module it is being built in
* @param {Object} opts Config log object being built
* Values in logMarkers object are intended for assignment to this arg
* @return {Object} contains a set of logging functions corresponding to available log levels
* A log won't display unless the global log level is higher than the log level tied
* to the function (e.g. if LOG_LEVEL=info, a message passed to log.debug won't show)
*/
export declare const logFactory: (config?: {} | AppConf) => (fileName: string, opts?: LogOpts) => MadLog;
/********************************************* EXPORT *********************************************/
export { logMarkers };
export * from './shared';
"use strict";
//
// TODO add sillyError, verboseError, debugError, infoError
// TODO add inspect
//
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
/************************************** THIRD-PARTY MODULES ***************************************/
var isNode = require("detect-node");
/**************************************** PROJECT MODULES *****************************************/
var build_file_tag_string_1 = require("./src/build-file-tag-string");
var theming_1 = require("./src/theming");
exports.logMarkers = theming_1.logMarkers;
/**
* Provide deprecation warning if buildFileTag used in the browser
*/
exports.buildFileTag = function (filenm, clrize, rpadLen) {
if (rpadLen === void 0) { rpadLen = 20; }
console.warn("DEPRECATION WARNING: mad-logs: buildFileTag method is intended for use in Node,");
console.warn(" & its inclusion in the browser build is now deprecated. Please import it from");
console.warn(" mad-logs/lib/node if using in Node, and remove uses from browser.");
return build_file_tag_string_1.buildFileTagString(filenm);
};
/********************************** CONFIG & LOG LEVEL HANDLING ***********************************/
// Default log level is info, if no config object given & no level set in the environment
var logLevelBase = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : 'info';
/**
* Default config options
*/
var defLogOpts = { tagPrefix: '', tagSuffix: '', style: '' };
var defConfig = { logLevel: logLevelBase };
/**
* Defines the available log levels in the application
*/
exports.logValues = { silly: 1, verbose: 2, debug: 3, info: 4, warn: 5, error: 6, wtf: 7 };
/**
* Get the log level value (number) corresponding to the log level string
*/
var getLogVal = function (logLvl) { return exports.logValues[logLvl]; };
/****************************************** COLOUR UTILS ******************************************/
/**
* Wrap text with tags to change the fg colour to yellow
* START TAG: \u001b[33m END TAG: \u001b[39m
*/
var yellow = function (text) { return "\u001B[33m" + text + "\u001B[39m"; };
/**
* Wrap text with tags to change the fg colour to red
* START TAG: \u001b[31m END TAG: \u001b[39m
*/
var red = function (text) { return "\u001B[31m" + text + "\u001B[39m"; };
/**
* Wrap text with tags to change the fg colour to white
* START TAG: \u001b[37m END TAG: \u001b[39m
*/
var white = function (text) { return "\u001B[37m" + text + "\u001B[39m"; };
/**
* Wrap text with tags to change the bg colour to red
* START TAG: \u001b[41m END TAG: \u001b[49m
*/
var bgRed = function (text) { return "\u001B[41m" + text + "\u001B[49m"; };
/**
* Wrap text with tags to change the fg colour to white
* START TAG: \u001b[47m END TAG: \u001b[49m
*/
var bgWhite = function (text) { return "\u001B[47m" + text + "\u001B[49m"; };
/****************************************** VERIFICATION ******************************************/
/**
* Ensure valid config object is passed in
* @param {Object} string must be one of the logValues object's keys to be valid
* @return {undefined} [This operates via side effects (thrown exception on fail)]
*/
var verifyConfig = function (config) {
if (!config)
return;
if (config.constructor.name === 'Array') {
throw new TypeError('Config object passed to mad-logs logFactory must not be an Array');
}
if (typeof config === 'object' && Object.keys(config).length === 0) {
return;
}
if (!config.logLevel) {
throw new TypeError('Config object passed to mad-logs logFactory must be null or have ' + 'key logLevel');
}
if (typeof config.logLevel !== 'string') {
throw new TypeError('Config.logLevel must be a string');
}
if (!Object.keys(exports.logValues).some(function (logValue) { return logValue === config.logLevel; })) {
throw new TypeError("config.logLevel must be one of the following: " + Object.keys(exports.logValues).join(', '));
}
};
/************************************ MAIN LOG OBJECT FACTORY *************************************/
/**
* Build 'logger' object for reuse throughout any module it's constructed in
* Strings passed to factory appear on the left of all logs emitted by functions in the returned
* object, easing identification (visually & by search) of logs emitted in a specific file/module
*
* @param {string} filename Name of the module it is being built in
* @param {Object} opts Config log object being built
* Values in logMarkers object are intended for assignment to this arg
* @return {Object} contains a set of logging functions corresponding to available log levels
* A log won't display unless the global log level is higher than the log level tied
* to the function (e.g. if LOG_LEVEL=info, a message passed to log.debug won't show)
*/
exports.logFactory = function (config) {
if (config === void 0) { config = defConfig; }
// Throw if invalid params given
verifyConfig(config);
return function buildLog(fileName, opts) {
if (opts === void 0) { opts = defLogOpts; }
var logLevelNum = getLogVal(config.logLevel || 'info');
var fileTag = buildFileTagForBrowser(fileName, opts);
var basicLog = function () {
var strs = [];
for (var _i = 0; _i < arguments.length; _i++) {
strs[_i] = arguments[_i];
}
console.log.apply(console, [fileTag, opts.style].concat(strs));
return strs[strs.length - 1];
};
/**
* Builder for logging fns called by (most) properties on outputted log function-object
*/
var logMethodFactory = function (lvl, out) {
if (out === void 0) { out = basicLog; }
return function () {
var strs = [];
for (var _i = 0; _i < arguments.length; _i++) {
strs[_i] = arguments[_i];
}
if (logLevelNum < lvl)
out.apply(void 0, strs);
return strs[strs.length - 1];
};
};
/************* CONSTRUCT LOG OBJECT METHODS FROM logMethodFactory **************/
var log = logMethodFactory(4);
log.silly = logMethodFactory(2);
log.verbose = logMethodFactory(3);
log.debug = logMethodFactory(4);
log.info = logMethodFactory(5);
log.warn = logMethodFactory(6, warnLogOut(fileTag));
/*********************** CONSTRUCT ERROR OBJECT METHOD *************************/
log.error = logMethodFactory(7, function () {
var strs = [];
for (var _i = 0; _i < arguments.length; _i++) {
strs[_i] = arguments[_i];
}
if (isNode) {
console.error.apply(console, [bgRed(white("[ERROR] " + fileTag)), ' :: '].concat(strs));
}
else {
console.error.apply(console, [fileTag, opts.style, ' [ERROR] '].concat(strs));
}
return strs[strs.length - 1];
});
/******************** CONSTRUCT SEVERE ERROR OBJECT METHOD *********************/
log.wtf = logMethodFactory(8, function () {
var strs = [];
for (var _i = 0; _i < arguments.length; _i++) {
strs[_i] = arguments[_i];
}
var wtfTag = "[! DANGER: FATAL ERROR !]";
if (isNode) {
// prettier-ignore
console.error.apply(console, ['\n', red(bgWhite(wtfTag + " " + fileTag)), ' :: '].concat(strs, ['\n']));
}
else {
console.error.apply(console, [fileTag, opts.style, " " + wtfTag + " "].concat(strs));
}
return strs[strs.length - 1];
});
/*********************************** HELPERS ***********************************/
function buildFileTagForBrowser(fileName, opts) {
return isNode
? "" + opts.tagPrefix + fileName + opts.tagSuffix
: "" + (opts.style ? '%c' : '') + opts.tagPrefix + "[" + fileName + "]" + opts.tagSuffix + " ";
}
/**
* Output a warning to the console with fileTag as a "marker" as ...strs as the output
*/
function warnLogOut(fileTag) {
return function () {
var strs = [];
for (var _i = 0; _i < arguments.length; _i++) {
strs[_i] = arguments[_i];
}
if (isNode) {
console.warn.apply(console, [yellow("[WARNING] " + fileTag), ' :: '].concat(strs));
}
else {
console.warn.apply(console, [fileTag, opts.style, ' [WARNING] '].concat(strs));
}
return strs[strs.length - 1];
};
}
/**************** EXPORT FINAL CONSTRUCTED LOG OBJECT-FUNCTION *****************/
return log;
};
};
__export(require("./shared"));
//# sourceMappingURL=index.js.map
import { isoStyles } from './src/isomorphic-styles';
/**************************************** TYPE DEFINITIONS ****************************************/
export interface Log {
silly: <T>(...args: Array<(string | any)>) => T;
verbose: <T>(...args: Array<(string | any)>) => T;
debug: <T>(...args: Array<(string | any)>) => T;
info: <T>(...args: Array<(string | any)>) => T;
warn: <T>(...args: Array<(string | any)>) => T;
error: <T>(...args: Array<(string | any)>) => T;
wtf: <T>(...args: Array<(string | any)>) => T;
}
/**
* Available log levels in the application
*/
export declare type LogLevels = keyof Log['inspector'];
/******************************************* LOG OBJECT *******************************************/
/**
* Isomorphic Log object
* Logs differently between Node and Browser
*
* Logs differently between node.js & browser when given the same styles
* Avoids need for separate browser & node modules
*/
export declare class Log implements Log {
export declare class Log {
/**
* If defined, use this value for inspecting objects
* Allows dependency injecting node's inspect in once, and getting it everywhere
* Allows dependency injecting node's inspect in once & getting it everywhere
*/

@@ -29,2 +26,5 @@ static inspectFn: Function;

*
* Provide [fileName], [style] item from Style object, and optionally
* [inspectFn] function to set as new global inspector of all Log objects
*
* @param {string} fileName Current file name, to include before each

@@ -34,8 +34,8 @@ * message this logger emits

* isoStyles' keys (string)
* If `none` is given, pass to console.log
* with fileName wrapped by [] & no styles
* If `none` given, pass to console.log with
* fileName wrapped by [] & no styles
* @param {Function?} inspectFn {OPTIONAL} If given, becomes new global
* inspector for all Log objects
* Uses a fallback inspect (passthrough) fn if
* none provided
* Uses a fallback inspect (passthrough)
* function if none provided
* Allows DI of node's inspect without having

@@ -52,2 +52,8 @@ * browser issues

wtf: <T>(...args: any[]) => T;
/**
* Object inspection
*
* Inspect object at any given level
* Both logs and shows inspect result
*/
inspector: {

@@ -74,5 +80,5 @@ silly: (obj: any) => string | void;

*/
export declare const logFactory: (filename: string, style?: ((fName: string) => string) | ((fName: string) => string[]) | "none" | "angryBird" | "aquarium" | "arrow" | "backAndForth" | "barbells" | "bracelet" | "brainwave" | "cantTouch" | "cartoonSwearing" | "checkmate" | "cult" | "default" | "dirtRoad" | "escherBarbieLego" | "farmerBrown" | "fresh" | "grasslands" | "hatBlock" | "hotPursuit" | "joy" | "kingRageBlock" | "lakeLouise" | "lucky" | "maceWindu" | "mechanicalAtFists" | "moProblems" | "mrsPotatoVHS" | "neverEnough" | "nightmare" | "pipeDream" | "ohMy" | "potOfGold" | "probeArcade" | "rainbowLeaf" | "rockIsDead" | "seafoamSalad" | "smokeyHatesChristmas" | "springy" | "swimmers" | "tangerines" | "theBird" | "theHeist" | "vendetta" | "xmlHell" | "zebra", inspector?: Function) => Log & ((...args: any[]) => void) & {
export declare const logFactory: (filename: string, style?: ((fName: string) => string) | ((fName: string) => string[]) | "none" | "angryBird" | "aquarium" | "arrow" | "backAndForth" | "barbells" | "bracelet" | "brainwave" | "cantTouch" | "cartoonSwearing" | "checkmate" | "cult" | "default" | "dirtRoad" | "escherBarbieLego" | "farmerBrown" | "fountain" | "fresh" | "grasslands" | "hatBlock" | "hotPursuit" | "joy" | "kingRageBlock" | "lakeLouise" | "lucky" | "maceWindu" | "mechanicalAtFists" | "moProblems" | "mrsPotatoVHS" | "neverEnough" | "nightmare" | "pipeDream" | "ohMy" | "potOfGold" | "probeArcade" | "rainbowLeaf" | "rockIsDead" | "seafoamSalad" | "smokeyHatesChristmas" | "springy" | "swimmers" | "tangerines" | "theBird" | "theHeist" | "vendetta" | "xmlHell" | "zebra", inspector?: Function) => Log & ((...args: any[]) => void) & {
inspect: (obj: any) => string | void;
};
export { isoStyles as Styles };

@@ -33,4 +33,2 @@ "use strict";

.concat(' :: \n${output}${bookend}'));
// console.log.apply(console, [bookend, `${styler(filename)} :: \n${output}${bookend}`);
// return output;
};

@@ -40,9 +38,15 @@ /******************************************* LOG OBJECT *******************************************/

* Isomorphic Log object
* Logs differently between Node and Browser
*
* Logs differently between node.js & browser when given the same styles
* Avoids need for separate browser & node modules
*/
var Log = /** @class */ (function () {
/* INITIALIZATION */
// TODO make setting global inspectFn separate from instantiation
/**
* Constructor for Log object
*
* Provide [fileName], [style] item from Style object, and optionally
* [inspectFn] function to set as new global inspector of all Log objects
*
* @param {string} fileName Current file name, to include before each

@@ -52,8 +56,8 @@ * message this logger emits

* isoStyles' keys (string)
* If `none` is given, pass to console.log
* with fileName wrapped by [] & no styles
* If `none` given, pass to console.log with
* fileName wrapped by [] & no styles
* @param {Function?} inspectFn {OPTIONAL} If given, becomes new global
* inspector for all Log objects
* Uses a fallback inspect (passthrough) fn if
* none provided
* Uses a fallback inspect (passthrough)
* function if none provided
* Allows DI of node's inspect without having

@@ -73,3 +77,3 @@ * browser issues

console.log.apply(console, (Array.isArray(tagObj) ? tagObj : [tagObj]).concat(args));
return args[0];
return args[args.length - 1];
}

@@ -85,3 +89,3 @@ };

console.log.apply(console, (Array.isArray(tagObj) ? tagObj : [tagObj]).concat(args));
return args[0];
return args[args.length - 1];
}

@@ -97,3 +101,3 @@ };

console.log.apply(console, (Array.isArray(tagObj) ? tagObj : [tagObj]).concat(args));
return args[0];
return args[args.length - 1];
}

@@ -109,3 +113,3 @@ };

console.log.apply(console, (Array.isArray(tagObj) ? tagObj : [tagObj]).concat(args));
return args[0];
return args[args.length - 1];
}

@@ -120,4 +124,4 @@ };

var tagObj = _this.styler(_this.filename);
console.log.apply(console, (Array.isArray(tagObj) ? tagObj : [tagObj]).concat(args));
return args[0];
console.warn.apply(console, (Array.isArray(tagObj) ? tagObj : [tagObj]).concat(args));
return args[args.length - 1];
}

@@ -161,3 +165,8 @@ };

};
/* OBJECT INSPECTION */
/**
* Object inspection
*
* Inspect object at any given level
* Both logs and shows inspect result
*/
this.inspector = (function () { return ({

@@ -164,0 +173,0 @@ silly: function (obj) {

@@ -172,2 +172,3 @@ /**

farmerBrown: ((fName: string) => string) | ((fName: string) => string[]);
fountain: ((fName: string) => string) | ((fName: string) => string[]);
fresh: ((fName: string) => string) | ((fName: string) => string[]);

@@ -174,0 +175,0 @@ grasslands: ((fName: string) => string) | ((fName: string) => string[]);

@@ -104,3 +104,3 @@ "use strict";

var angryBird = isNode
? function (fName) { return bgYellow(black("\uD83D\uDC25 [" + fName + "]\uD83D\uDC25 ")) + ' '; }
? function (fName) { return bgYellow(black("\uD83D\uDC25 " + fName + " \uD83D\uDC25 ")) + ' '; }
: function (fName) { return [

@@ -111,3 +111,3 @@ buildFileTag(fName, theming_1.madLogMarkers.angryBird),

var aquarium = isNode
? function (fName) { return bgBlue(white(bold("\uD83D\uDC20 \uD83D\uDC19 [" + fName + "]\uD83D\uDC19 \uD83D\uDC20 "))) + ' '; }
? function (fName) { return bgBlue(white(bold("\uD83D\uDC20 \uD83D\uDC19 " + fName + " \uD83D\uDC19 \uD83D\uDC20 "))) + ' '; }
: function (fName) { return [

@@ -118,3 +118,3 @@ buildFileTag(fName, theming_1.madLogMarkers.aquarium),

var arrow = isNode
? function (fName) { return gray(bold(bgWhite("--[" + fName + "]-->"))) + ' '; }
? function (fName) { return gray(bold(bgWhite(">>--[" + fName + "]-->"))) + ' '; }
: function (fName) { return [

@@ -137,3 +137,3 @@ buildFileTag(fName, theming_1.madLogMarkers.arrow),

var bracelet = isNode
? function (fName) { return bold(bgMagenta(cyan("\u231A [" + fName + "]\u231A "))) + ' '; }
? function (fName) { return bold(bgMagenta(cyan("\u231A " + fName + " \u231A "))) + ' '; }
: function (fName) { return [

@@ -150,3 +150,3 @@ buildFileTag(fName, theming_1.madLogMarkers.bracelet),

var cantTouch = isNode
? function (fName) { return bold(bgCyan(white("\u270B \uD83D\uDD28 \u23F0 [" + fName + "]\u270B \uD83D\uDD28 \u23F0 "))) + ' '; }
? function (fName) { return bold(bgCyan(white("\u270B \uD83D\uDD28 \u23F0 " + fName + " \u270B \uD83D\uDD28 \u23F0 "))) + ' '; }
: function (fName) { return [

@@ -157,3 +157,3 @@ buildFileTag(fName, theming_1.madLogMarkers.cantTouch),

var cartoonSwearing = isNode
? function (fName) { return underline(bgCyan(red("@%@%! [" + fName + "] !@%@%"))) + ' '; }
? function (fName) { return underline(bgCyan(red("@%@%! " + fName + " !@%@%"))) + ' '; }
: function (fName) { return [

@@ -164,3 +164,3 @@ buildFileTag(fName, theming_1.madLogMarkers.cartoonSwearing),

var checkmate = isNode
? function (fName) { return bgYellow(black("\u265C \u265E \u265D \u265A \u265B [" + fName + "]\u265B \u265A \u265D \u265E \u265C ")) + ' '; }
? function (fName) { return bgYellow(black("\u265C \u265E \u265D \u265A \u265B " + fName + " \u265B \u265A \u265D \u265E \u265C ")) + ' '; }
: function (fName) { return [

@@ -171,3 +171,3 @@ buildFileTag(fName, theming_1.madLogMarkers.checkmate),

var cult = isNode
? function (fName) { return bold(bgRed(cyan("\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC66 \uD83D\uDC6A [" + fName + "] \uD83D\uDC6A \uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC66 "))) + ' '; }
? function (fName) { return bold(bgRed(cyan("\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC66 \uD83D\uDC6A " + fName + " \uD83D\uDC6A \uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC66 "))) + ' '; }
: function (fName) { return [

@@ -184,3 +184,3 @@ buildFileTag(fName, theming_1.madLogMarkers.cult),

var escherBarbieLego = isNode
? function (fName) { return bgMagenta(black("||\u2517\u251B\u250F\u2513 [" + fName + "] \u250F\u2513\u2517\u251B||")) + ' '; }
? function (fName) { return bgMagenta(black("||\u2517\u251B\u250F\u2513 " + fName + " \u250F\u2513\u2517\u251B||")) + ' '; }
: function (fName) { return [

@@ -191,3 +191,3 @@ buildFileTag(fName, theming_1.madLogMarkers.escherBarbieLego),

var farmerBrown = isNode
? function (fName) { return bold(white(bgGreen("\uD83D\uDC11 \uD83D\uDC02 [" + fName + "]\uD83D\uDC02 \uD83D\uDC11 "))) + ' '; }
? function (fName) { return bold(white(bgGreen("\uD83D\uDC11 \uD83D\uDC02 " + fName + " \uD83D\uDC02 \uD83D\uDC11 "))) + ' '; }
: function (fName) { return [

@@ -197,2 +197,8 @@ buildFileTag(fName, theming_1.madLogMarkers.farmerBrown),

]; };
var fountain = isNode
? function (fName) { return white(bgBlack("\uD83D\uDE4F " + fName + " \uD83D\uDE4F ")) + ' '; }
: function (fName) { return [
buildFileTag(fName, theming_1.madLogMarkers.fountain),
theming_1.madLogMarkers.fountain.style,
]; };
var fresh = isNode

@@ -211,3 +217,3 @@ ? function (fName) { return white(bgMagenta("\uD83D\uDCD6 \uD83D\uDC76 >\uD83D\uDC75 \uD83D\uDD04 " + fName + " \u231B \uD83D\uDCBA \u2B05\uFE0F \uD83D\uDC51 \uD83D\uDD14 \uD83D\uDCA8 ")) + ' '; }

var hatBlock = isNode
? function (fName) { return bgCyan(black("\uD83C\uDFA9 [" + fName + "] \uD83C\uDFA9 ")) + ' '; }
? function (fName) { return bgCyan(black("\uD83C\uDFA9 " + fName + " \uD83C\uDFA9 ")) + ' '; }
: function (fName) { return [

@@ -218,3 +224,3 @@ buildFileTag(fName, theming_1.madLogMarkers.hatBlock),

var hotPursuit = isNode
? function (fName) { return bgRed(white(bold("\uD83C\uDF6F \uD83D\uDC3B [" + fName + "]\uD83D\uDC1D \uD83D\uDC1D "))) + ' '; }
? function (fName) { return bgRed(white(bold("\uD83C\uDF6F \uD83D\uDC3B " + fName + " \uD83D\uDC1D \uD83D\uDC1D "))) + ' '; }
: function (fName) { return [

@@ -225,3 +231,3 @@ buildFileTag(fName, theming_1.madLogMarkers.hotPursuit),

var joy = isNode
? function (fName) { return bgYellow(black("\uD83D\uDE00 \uD83D\uDE00 [" + fName + "]\uD83D\uDE00 \uD83D\uDE00 ")) + ' '; }
? function (fName) { return bgYellow(black("\uD83D\uDE00 \uD83D\uDE00 " + fName + " \uD83D\uDE00 \uD83D\uDE00 ")) + ' '; }
: function (fName) { return [

@@ -232,3 +238,3 @@ buildFileTag(fName, theming_1.madLogMarkers.joy),

var kingRageBlock = isNode
? function (fName) { return bgRed(white(bold("\uD83D\uDC41\u200D\uD83D\uDDE8 \uD83D\uDDE3 \uD83D\uDDEF [" + fName + "]\uD83D\uDC41\u200D\uD83D\uDDE8 \uD83D\uDDE3 \uD83D\uDDEF "))) + ' '; }
? function (fName) { return bgRed(white(bold("\uD83D\uDC41\u200D\uD83D\uDDE8 \uD83D\uDDE3 \uD83D\uDDEF " + fName + " \uD83D\uDC41\u200D\uD83D\uDDE8 \uD83D\uDDE3 \uD83D\uDDEF "))) + ' '; }
: function (fName) { return [

@@ -239,3 +245,3 @@ buildFileTag(fName, theming_1.madLogMarkers.kingRageBlock),

var lakeLouise = isNode
? function (fName) { return bgCyan(white(bold("\uD83C\uDFDE\uFE0F [" + fName + "] \uD83C\uDFDE\uFE0F "))) + ' '; }
? function (fName) { return bgCyan(white(bold("\uD83C\uDFDE\uFE0F " + fName + " \uD83C\uDFDE\uFE0F "))) + ' '; }
: function (fName) { return [

@@ -246,3 +252,3 @@ buildFileTag(fName, theming_1.madLogMarkers.lakeLouise),

var lucky = isNode
? function (fName) { return bold(white(bgGreen("\uD83C\uDF40 [" + fName + "]\uD83C\uDF40 "))) + ' '; }
? function (fName) { return bold(white(bgYellow("\uD83C\uDF40 " + fName + " \uD83C\uDF40 "))) + ' '; }
: function (fName) { return [

@@ -271,3 +277,3 @@ buildFileTag(fName, theming_1.madLogMarkers.lucky),

var mrsPotatoVHS = isNode
? function (fName) { return underline(black(bgYellow("(\uD83D\uDC43 \uD83D\uDC41 \uD83D\uDC42) " + fName + " (\uD83D\uDC42 \uD83D\uDC41 \uD83D\uDC45 )"))) + ' '; }
? function (fName) { return underline(black(bgYellow("\uD83D\uDC43 \uD83D\uDC41 \uD83D\uDC42 " + fName + " \uD83D\uDC42 \uD83D\uDC41 \uD83D\uDC45 "))) + ' '; }
: function (fName) { return [

@@ -278,3 +284,3 @@ buildFileTag(fName, theming_1.madLogMarkers.mrsPotatoVHS),

var neverEnough = isNode
? function (fName) { return bold(blue(bgWhite("\uD83D\uDD14 \uD83D\uDC2E \uD83D\uDD14 [" + fName + "]\uD83D\uDD14 \uD83D\uDC2E \uD83D\uDD14 "))) + ' '; }
? function (fName) { return bold(blue(bgWhite("\uD83D\uDD14 \uD83D\uDC2E \uD83D\uDD14 " + fName + " \uD83D\uDD14 \uD83D\uDC2E \uD83D\uDD14 "))) + ' '; }
: function (fName) { return [

@@ -303,3 +309,3 @@ buildFileTag(fName, theming_1.madLogMarkers.neverEnough),

var potOfGold = isNode
? function (fName) { return italic(bold(yellow(bgBlack("\uD83D\uDCB0 [" + fName + "] \uD83D\uDCB0 ")))) + ' '; }
? function (fName) { return italic(bold(yellow(bgBlack("\uD83D\uDCB0 " + fName + " \uD83D\uDCB0 ")))) + ' '; }
: function (fName) { return [

@@ -310,3 +316,3 @@ buildFileTag(fName, theming_1.madLogMarkers.potOfGold),

var probeArcade = isNode
? function (fName) { return bold(cyan(bgBlue("\uD83D\uDC7D [" + fName + "] \uD83D\uDC7D "))) + ' '; }
? function (fName) { return bold(cyan(bgBlue("\uD83D\uDC7D " + fName + " \uD83D\uDC7D "))) + ' '; }
: function (fName) { return [

@@ -317,3 +323,3 @@ buildFileTag(fName, theming_1.madLogMarkers.probeArcade),

var rainbowLeaf = isNode
? function (fName) { return '🌈 ' + rainbow("[" + fName + "]") + ' 🌈 '; }
? function (fName) { return '🌈 ' + rainbow(fName) + ' 🌈 '; }
: function (fName) { return [

@@ -324,3 +330,3 @@ buildFileTag(fName, theming_1.madLogMarkers.rainbowLeaf),

var rockIsDead = isNode
? function (fName) { return bold(bgBlack(magenta("\uD83C\uDFB8 [" + fName + "] \uD83C\uDFB8 "))) + ' '; }
? function (fName) { return bold(bgBlack(magenta("\uD83C\uDFB8 " + fName + " \uD83C\uDFB8 "))) + ' '; }
: function (fName) { return [

@@ -337,3 +343,3 @@ buildFileTag(fName, theming_1.madLogMarkers.rockIsDead),

var smokeyHatesChristmas = isNode
? function (fName) { return white(bold(bgGreen("\uD83C\uDF84 \uD83D\uDD25 [" + fName + "]\uD83D\uDD25 \uD83C\uDF84 "))) + ' '; }
? function (fName) { return white(bold(bgGreen("\uD83C\uDF84 \uD83D\uDD25 " + fName + " \uD83D\uDD25 \uD83C\uDF84 "))) + ' '; }
: function (fName) { return [

@@ -344,3 +350,3 @@ buildFileTag(fName, theming_1.madLogMarkers.smokeyHatesChristmas),

var springy = isNode
? function (fName) { return underline(bold(white("\u2699\uFE0F [" + fName + "] \u2699\uFE0F "))) + ' '; }
? function (fName) { return underline(bold(white("\u2699\uFE0F " + fName + " \u2699\uFE0F "))) + ' '; }
: function (fName) { return [

@@ -357,3 +363,3 @@ buildFileTag(fName, theming_1.madLogMarkers.springy),

var tangerines = isNode
? function (fName) { return '🍊 ' + rainbow("[" + fName + "]") + ' 🍊 '; }
? function (fName) { return '🍊 ' + rainbow(fName) + ' 🍊 '; }
: function (fName) { return [

@@ -364,3 +370,3 @@ buildFileTag(fName, theming_1.madLogMarkers.tangerines),

var theBird = isNode
? function (fName) { return white(bold(bgMagenta("\uD83D\uDD95\uD83C\uDFFC [" + fName + "]\uD83D\uDD95\uD83C\uDFFC "))) + ' '; }
? function (fName) { return white(bold(bgMagenta("\uD83D\uDD95\uD83C\uDFFC " + fName + " \uD83D\uDD95\uD83C\uDFFC "))) + ' '; }
: function (fName) { return [

@@ -415,2 +421,3 @@ buildFileTag(fName, theming_1.madLogMarkers.theBird),

farmerBrown: farmerBrown,
fountain: fountain,
fresh: fresh,

@@ -417,0 +424,0 @@ grasslands: grasslands,

@@ -126,2 +126,7 @@ /************************************************************************************************

};
fountain: {
tagPrefix: string;
tagSuffix: string;
style: string;
};
fresh: {

@@ -359,2 +364,7 @@ tagPrefix: string;

};
fountain: {
tagPrefix: string;
tagSuffix: string;
style: string;
};
fresh: {

@@ -361,0 +371,0 @@ tagPrefix: string;

@@ -154,2 +154,10 @@ "use strict";

},
fountain: {
tagPrefix: '🙏 ',
tagSuffix: ' 🙏 ',
// Colour is an ultra-dark blue
style: "font-size: 18px; background-color: steelblue; color: #02025d;" +
"border-top-left-radius: 25px; border-top-right-radius: 2px;" +
"border-bottom-right-radius: 2px",
},
fresh: {

@@ -156,0 +164,0 @@ tagPrefix: '📖 👶>👵 🔄',

@@ -5,7 +5,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
// Ensure environment knows testing is occurring
process.env.mocha = true;
// Fix process.argv to work with colors
process.argv = Array.from(process.argv) || [];
global.process.argv = Array.from(global.process.argv) || process.argv || [];
/************************************** THIRD-PARTY IMPORTS ***************************************/

@@ -17,39 +12,24 @@ var chai_1 = require("chai");

var sharedMadLogs = require("../shared");
var theming_1 = require("../src/theming");
/******************************************** HELPERS *********************************************/
/**
* Prevents console.error messages emitted by code from reaching the console for given function
* @param {Function} fn function to run without showing errors
* @return {Object<{errorLogs: string[], warnLogs: string[], result: any}>} array containing
* warnings & errors outputted running the function & the function result
* Visually test an isomorphic style
* Ensure it looks good when outputted, by visual inspection
* These will automatically pass if they don't throw
*/
function blockErrorOutput(fn) {
var errorLogs = [];
var warnLogs = [];
var errorOrig = console.error;
console.error = function () {
var msgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
msgs[_i] = arguments[_i];
}
return errorLogs.push(msgs);
};
var warnOrig = console.warn;
console.warn = function () {
var msgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
msgs[_i] = arguments[_i];
}
return warnLogs.push(msgs);
};
var result = fn();
console.error = errorOrig;
console.warn = warnOrig;
return { errorLogs: errorLogs, warnLogs: warnLogs, result: result };
}
function testIsoStyle(styleName) {
function visualTestIsoStyle(styleName) {
it(styleName, function () {
var log = sharedMadLogs.logFactory('MadLogs.test', sharedMadLogs.Styles[styleName]);
var log = sharedMadLogs.logFactory("MadLogs.test", sharedMadLogs.Styles[styleName]);
log.info("Test log :: " + styleName + " style");
});
}
/**
* Fully test style [styleName]
*
* Explain what it adds to a log message with [whatItAddsMsg] arg
*
* Ensure it logs, and has output where all [expectedContents] strings and
* [expectedMatches] RegExps are partial matches (i.e. they return a match, but
* don't need to match the whole string)
*/
function styleTester(styleName, whatItAddsMsg, expectedContents, expectedMatches) {

@@ -59,6 +39,6 @@ if (expectedContents === void 0) { expectedContents = []; }

it("has style " + styleName + ", which adds " + whatItAddsMsg + " to output if used in log constructor", function () {
var eblLogger = index_1.logFactory()('mad-logs.test.ts', index_1.logMarkers[styleName]);
var eblLogger = index_1.logFactory("mad-logs.test.ts", index_1.Styles[styleName]);
// Stub console.log and most of console's internals
var output = test_console_1.stdout.inspectSync(function () {
eblLogger('Should be logged');
eblLogger("Should be logged");
});

@@ -70,3 +50,3 @@ // Display the actual log output if verbose mode is on

}
var stringsExpectedInOutput = ['mad-logs.test.ts'].concat(expectedContents);
var stringsExpectedInOutput = ["mad-logs.test.ts"].concat(expectedContents);
stringsExpectedInOutput.forEach(function (str) { return chai_1.expect(output[0]).to.contain(str); });

@@ -77,42 +57,23 @@ expectedMatches.forEach(function (match) { return chai_1.expect(output[0]).to.match(match); });

/********************************************* TESTS **********************************************/
describe('logFactory', function () {
it('exists', function () {
describe("logFactory", function () {
it("exists", function () {
chai_1.expect(index_1.logFactory).to.exist;
});
it('returns a function when given a config object with a valid log level', function () {
['silly', 'verbose', 'debug', 'info', 'warn', 'error', 'wtf'].forEach(function (lvl) {
chai_1.expect(index_1.logFactory({ logLevel: lvl })).to.be.a('function');
});
chai_1.expect(index_1.logFactory({ logLevel: 'info' })).to.be.a('function');
it("returns function if given filename & style)", function () {
chai_1.expect(function () { return index_1.logFactory("mad-logs.test.ts", index_1.Styles.dirtRoad); }).to.not.throw(TypeError);
chai_1.expect(index_1.logFactory("mad-logs.test.ts", index_1.Styles.dirtRoad)).to.be.a("function");
});
it('returns function if given no config object (this triggers default log level)', function () {
chai_1.expect(index_1.logFactory).to.not.throw(TypeError);
chai_1.expect(index_1.logFactory()).to.be.a('function');
});
it('throws TypeError if given an invalid log level or config object', function () {
chai_1.expect(function () { return index_1.logFactory(['asdf']); }).to.throw(TypeError);
chai_1.expect(function () { return index_1.logFactory({ gr: 'arg' }); }).to.throw(TypeError);
chai_1.expect(function () { return index_1.logFactory({ logLevel: {} }); }).to.throw(TypeError);
chai_1.expect(function () { return index_1.logFactory({ logLevel: 'notARealLevel' }); }).to.throw(TypeError);
chai_1.expect(function () { return index_1.logFactory({ logLevel: '' }); }).to.throw(TypeError);
});
it('does not throw TypeError if given no args, null, or an empty config object', function () {
chai_1.expect(function () { return index_1.logFactory(); }).to.not.throw(TypeError);
chai_1.expect(function () { return index_1.logFactory(null); }).to.not.throw(TypeError);
chai_1.expect(function () { return index_1.logFactory({}); }).to.not.throw(TypeError);
});
describe('log function constructed by logFactory (with no styling)', function () {
describe("log function constructed by logFactory (with no styling)", function () {
var logger;
before(function () {
var config = { logLevel: 'silly' };
logger = index_1.logFactory(config)('mad-logs.test');
logger = index_1.logFactory("mad-logs.test.ts", index_1.Styles.cult);
});
it('returns log function w/ props for each logLvl when given config & filename', function () {
it("returns log function w/ props for each logLvl when given config & filename", function () {
chai_1.expect(logger).to.exist;
chai_1.expect(logger).to.be.a('function');
['silly', 'verbose', 'debug', 'info', 'warn', 'error', 'wtf'].forEach(function (methodName) {
chai_1.expect(logger).to.be.a("function");
["silly", "verbose", "debug", "info", "warn", "error", "wtf"].forEach(function (methodName) {
chai_1.expect(logger).to.have.property(methodName);
});
});
it('writes to terminal, including a tag w/ filename received by constructor', function () {
it("writes to terminal, including a tag w/ filename received by constructor", function () {
var storeWarnErrorLogs = [];

@@ -123,2 +84,3 @@ // Stub console.log and most of console's internals

var warnOrig = console.warn;
var errorOrig = console.error;
console.warn = function () {

@@ -131,3 +93,2 @@ var msgs = [];

};
var errorOrig = console.error;
console.error = function () {

@@ -141,10 +102,9 @@ var msgs = [];

// Log using the library, with the console fully stubbed
logger('testOutputBaseLog');
logger.silly('testOutputSilly');
logger.verbose('testOutputVerbose');
logger.debug('testOutputDebug');
logger.info('testOutputInfo');
logger.warn('testOutputWarn');
logger.error('testOutputError');
logger.wtf('testOutputWtf');
logger.silly("testOutputSilly");
logger.verbose("testOutputVerbose");
logger.debug("testOutputDebug");
logger.info("testOutputInfo");
logger.warn("testOutputWarn");
logger.error("testOutputError");
logger.wtf("testOutputWtf");
// Restore the remaining console methods

@@ -155,63 +115,84 @@ console.warn = warnOrig;

// Test against the text intended for the terminal (but captured by the stub)
chai_1.expect(output).to.have.members([
'mad-logs.test testOutputBaseLog\n',
'mad-logs.test testOutputSilly\n',
'mad-logs.test testOutputVerbose\n',
'mad-logs.test testOutputDebug\n',
'mad-logs.test testOutputInfo\n',
]);
// Ensure the console outputs reached the console.warn & .error using log methods
chai_1.expect(storeWarnErrorLogs.some(function (curLog) { return curLog.some(function (lBit) { return lBit === 'testOutputWarn'; }); })).to.be.true;
chai_1.expect(storeWarnErrorLogs.some(function (curLog) { return curLog.some(function (lBit) { return lBit === 'testOutputError'; }); })).to.be.true;
chai_1.expect(storeWarnErrorLogs.some(function (curLog) { return curLog.some(function (lBit) { return lBit === 'testOutputWtf'; }); }))
.to.be.true;
output.forEach(function (out) {
if (env_var_helpers_1.isVerbose)
console.log("HERE :: out:", out);
chai_1.expect(out).to.match(/mad\-logs\.test/);
});
chai_1.expect(!!output[0].match(/testOutputSilly/)).to.be.true;
chai_1.expect(!!output[1].match(/testOutputVerbose/)).to.be.true;
chai_1.expect(!!output[2].match(/testOutputDebug/)).to.be.true;
chai_1.expect(!!output[3].match(/testOutputInfo/)).to.be.true;
if (env_var_helpers_1.isVerbose)
console.log("[0] storeWarnErrorLogs:", storeWarnErrorLogs);
// Ensure the console outputs reached console.warn & .error using log methods
chai_1.expect(storeWarnErrorLogs.some(function (curLog) {
return curLog.some(function (lBit) {
if (env_var_helpers_1.isVerbose)
console.log("[1] storeWarnErrorLogs --> lBit:", lBit);
return lBit === "testOutputWarn";
});
})).to.be.true;
chai_1.expect(storeWarnErrorLogs.some(function (curLog) {
return curLog.some(function (lBit) {
if (env_var_helpers_1.isVerbose)
console.log("[2] storeWarnErrorLogs --> lBit:", lBit);
return lBit === "testOutputError";
});
})).to.be.true;
chai_1.expect(storeWarnErrorLogs.some(function (curLog) {
return curLog.some(function (lBit) {
if (env_var_helpers_1.isVerbose)
console.log("[3] storeWarnErrorLogs --> lBit:", lBit);
return lBit === "testOutputWtf";
});
})).to.be.true;
});
it('All log instance methods return last arg given, when 1 args provided', function () {
chai_1.expect(logger.silly('omnomnom')).to.eql('omnomnom');
chai_1.expect(logger.verbose('omnomnom')).to.eql('omnomnom');
chai_1.expect(logger.info('omnomnom')).to.eql('omnomnom');
chai_1.expect(logger.warn('omnomnom')).to.eql('omnomnom');
chai_1.expect(logger.error('omnomnom')).to.eql('omnomnom');
chai_1.expect(logger.wtf('omnomnom')).to.eql('omnomnom');
it("All log instance methods return last arg given, when 1 args provided", function () {
chai_1.expect(logger.silly("omnomnom")).to.eql("omnomnom");
chai_1.expect(logger.verbose("omnomnom")).to.eql("omnomnom");
chai_1.expect(logger.info("omnomnom")).to.eql("omnomnom");
chai_1.expect(logger.warn("omnomnom")).to.eql("omnomnom");
chai_1.expect(logger.error("omnomnom")).to.eql("omnomnom");
chai_1.expect(logger.wtf("omnomnom")).to.eql("omnomnom");
});
it('All log instance methods return last arg given, when 2 args provided', function () {
chai_1.expect(logger.silly('tickaTickaBoomTicka', 'BoomTickaBoom')).to.eql('BoomTickaBoom');
chai_1.expect(logger.verbose('tickaTickaBoomTicka', 'BoomTickaBoom')).to.eql('BoomTickaBoom');
chai_1.expect(logger.info('tickaTickaBoomTicka', 'BoomTickaBoom')).to.eql('BoomTickaBoom');
chai_1.expect(logger.warn('tickaTickaBoomTicka', 'BoomTickaBoom')).to.eql('BoomTickaBoom');
chai_1.expect(logger.error('tickaTickaBoomTicka', 'BoomTickaBoom')).to.eql('BoomTickaBoom');
chai_1.expect(logger.wtf('tickaTickaBoomTicka', 'BoomTickaBoom')).to.eql('BoomTickaBoom');
it("All log instance methods return last arg given, when 2 args provided", function () {
chai_1.expect(logger.silly("tickaTickaBoomTicka", "BoomTickaBoom")).to.eql("BoomTickaBoom");
chai_1.expect(logger.verbose("tickaTickaBoomTicka", "BoomTickaBoom")).to.eql("BoomTickaBoom");
chai_1.expect(logger.info("tickaTickaBoomTicka", "BoomTickaBoom")).to.eql("BoomTickaBoom");
chai_1.expect(logger.warn("tickaTickaBoomTicka", "BoomTickaBoom")).to.eql("BoomTickaBoom");
chai_1.expect(logger.error("tickaTickaBoomTicka", "BoomTickaBoom")).to.eql("BoomTickaBoom");
chai_1.expect(logger.wtf("tickaTickaBoomTicka", "BoomTickaBoom")).to.eql("BoomTickaBoom");
});
it('All log instance methods return last arg given, when 4 args provided', function () {
chai_1.expect(logger.silly('tingtang', 'wallawalla', 'bing', 'bang')).to.eql('bang');
chai_1.expect(logger.verbose('tingtang', 'wallawalla', 'bing', 'bang')).to.eql('bang');
chai_1.expect(logger.info('tingtang', 'wallawalla', 'bing', 'bang')).to.eql('bang');
chai_1.expect(logger.warn('tingtang', 'wallawalla', 'bing', 'bang')).to.eql('bang');
chai_1.expect(logger.error('tingtang', 'wallawalla', 'bing', 'bang')).to.eql('bang');
chai_1.expect(logger.wtf('tingtang', 'wallawalla', 'bing', 'bang')).to.eql('bang');
it("All log instance methods return last arg given, when 4 args provided", function () {
chai_1.expect(logger.silly("tingtang", "wallawalla", "bing", "bang")).to.eql("bang");
chai_1.expect(logger.verbose("tingtang", "wallawalla", "bing", "bang")).to.eql("bang");
chai_1.expect(logger.info("tingtang", "wallawalla", "bing", "bang")).to.eql("bang");
chai_1.expect(logger.warn("tingtang", "wallawalla", "bing", "bang")).to.eql("bang");
chai_1.expect(logger.error("tingtang", "wallawalla", "bing", "bang")).to.eql("bang");
chai_1.expect(logger.wtf("tingtang", "wallawalla", "bing", "bang")).to.eql("bang");
});
});
});
describe('logMarkers', function () {
describe("Styles", function () {
var styles = [
'lakeLouise',
'farmerBrown',
'escherBarbieLego',
'smokeyHatesChristmas',
'barbells',
'angryBird',
'zebra',
'vendetta',
'moProblems',
'theHeist',
'vendetta',
'rockIsDead',
'mechanicalAtFists',
'nightmare',
'tangerines',
'maceWindu',
'grasslands',
'default',
'cartoonSwearing',
'backAndForth',
"lakeLouise",
"farmerBrown",
"escherBarbieLego",
"smokeyHatesChristmas",
"barbells",
"angryBird",
"zebra",
"vendetta",
"moProblems",
"theHeist",
"vendetta",
"rockIsDead",
"mechanicalAtFists",
"nightmare",
"tangerines",
"maceWindu",
"grasslands",
"default",
"cartoonSwearing",
"backAndForth",
];

@@ -221,35 +202,35 @@ // tslint:disable

{
name: 'arrow',
outMatch: />>--mad-logs.test.ts---\|> Should be logged\n/,
name: "arrow",
outMatch: />>--\[mad\-logs\.test\.ts\]-->.* Should be logged/,
},
{
name: 'brainwave',
outMatch: /~\^~\^~\^-mad-logs.test.ts-~\^~\^~\^ color: #003366 Should be logged\n/,
name: "brainwave",
outMatch: /~\^~\^~\[mad\-logs\.test\.ts\]~\^~\^~.* Should be logged\n/,
},
{
name: 'checkmate',
outMatch: /♜♞♝♚♛♝♞♜_ \[mad-logs.test\.ts\] _♟♟♟♟♟♟♟♟ color: #593001 Should be logged/,
name: "checkmate",
outMatch: /♜ ♞ ♝ ♚ ♛ mad\-logs\.test\.ts ♛ ♚ ♝ ♞ ♜.* Should be logged/,
},
{
name: 'hotPursuit',
outMatch: /🎄🎄 !🍯🐻\-\-\-🎄!🐝🐝\-\-\- \[mad-logs.test\.ts\] !🐝🐝🐝🐝\-\-\- 🎄🎄 color: #000000; background-color: orange Should be logged/,
name: "hotPursuit",
outMatch: /🍯 🐻 mad\-logs\.test\.ts 🐝 🐝.* Should be logged/,
},
{
name: 'pipeDream',
outMatch: /┣╋━╋~🛀~╋━╋┫ mad-logs.test\.ts ┣┫ color: #777777; background-color: #FFFFFF; font-weight: bold; Should be logged/,
name: "pipeDream",
outMatch: /┣╋━╋~🛀 mad\-logs\.test\.ts 🛀~╋━╋┫.* Should be logged/,
},
];
// tslint:enable
it('exists', function () {
chai_1.expect(index_1.logMarkers).to.exist;
it("exists", function () {
chai_1.expect(index_1.Styles).to.exist;
});
it('has over 20 defined styles', function () {
chai_1.expect(Object.keys(index_1.logMarkers)).to.have.length.above(20);
it("has over 20 defined styles", function () {
chai_1.expect(Object.keys(index_1.Styles)).to.have.length.above(20);
});
it('only contains objects with keys tagPrefix, tagSuffix, and style', function () {
Object.keys(index_1.logMarkers).forEach(function (markerKey) {
var curLogMarker = index_1.logMarkers[markerKey];
chai_1.expect(curLogMarker.tagPrefix).to.be.a('string');
chai_1.expect(curLogMarker.tagSuffix).to.be.a('string');
chai_1.expect(curLogMarker.style).to.be.a('string');
it("only contains objects with keys tagPrefix, tagSuffix, and style", function () {
Object.keys(theming_1.madLogMarkers).forEach(function (markerKey) {
var curLogMarker = theming_1.madLogMarkers[markerKey];
chai_1.expect(curLogMarker.tagPrefix).to.be.a("string");
chai_1.expect(curLogMarker.tagSuffix).to.be.a("string");
chai_1.expect(curLogMarker.style).to.be.a("string");
});

@@ -260,3 +241,3 @@ });

it("includes style " + style, function () {
chai_1.expect(Object.keys(index_1.logMarkers)).to.contain(style);
chai_1.expect(Object.keys(theming_1.madLogMarkers)).to.contain(style);
});

@@ -266,19 +247,19 @@ });

it("includes style 'arrow', which includes prefix >>-- and suffix ---|>", function () {
chai_1.expect(index_1.logMarkers.arrow).to.exist;
chai_1.expect(index_1.logMarkers.arrow.tagPrefix).to.match(/>>--/);
chai_1.expect(index_1.logMarkers.arrow.tagSuffix).to.match(/--|>/);
chai_1.expect(theming_1.madLogMarkers.arrow).to.exist;
chai_1.expect(theming_1.madLogMarkers.arrow.tagPrefix).to.match(/>>--/);
chai_1.expect(theming_1.madLogMarkers.arrow.tagSuffix).to.match(/--|>/);
});
// Another example to include style with emojis
it("includes style 'rockIsDead', which includes \uD83D\uDC80\u2620\uD83C\uDFB8\uD83D\uDC80\uD83D\uDC8E\uD83D\uDC80, \uD83D\uDC83\uD83D\uDC83\uD83D\uDC83\uD83C\uDFA7\uD83D\uDE03, etc.", function () {
chai_1.expect(index_1.logMarkers.rockIsDead).to.exist;
chai_1.expect(index_1.logMarkers.rockIsDead.tagPrefix).to.match(/💀☠🎸💀💎💀🎸💀 \|/);
chai_1.expect(index_1.logMarkers.rockIsDead.tagSuffix).to.match(/\| 😃🔊♪♪💃💃💃💃💃🎧😃/);
chai_1.expect(theming_1.madLogMarkers.rockIsDead).to.exist;
chai_1.expect(theming_1.madLogMarkers.rockIsDead.tagPrefix).to.match(/💀☠🎸💀💎💀🎸💀 \|/);
chai_1.expect(theming_1.madLogMarkers.rockIsDead.tagSuffix).to.match(/\| 😃🔊♪♪💃💃💃💃💃🎧😃/);
});
// Ensure expected styles included & give expected output when used in a log [non-exhaustive]
stylesWMatch.forEach(function (style) {
var logger = index_1.logFactory()('mad-logs.test.ts', index_1.logMarkers[style.name]);
it("has style " + style.name + ", w/ output that matches " + style.outMatch.toString(), function () {
var logger = index_1.logFactory("mad-logs.test.ts", index_1.Styles[style.name]);
it("has style " + style.name + ", w/ output matching " + style.outMatch.toString(), function () {
// Stub console.log and most of console's internals
var output = test_console_1.stdout.inspectSync(function () {
logger('Should be logged');
logger("Should be logged");
});

@@ -295,64 +276,61 @@ if (env_var_helpers_1.isVerbose) {

});
styleTester('arrow', '>>-- & ---|>', [], [/>>--mad-logs.test.ts---\|> Should be logged/]);
styleTester('escherBarbieLego', '||┗┛┏┓ & ┏┓┗┛|| (and various styles)', [], [
/\|\|┗┛┏┓mad-logs.test.ts┏┓┗┛\|\| color: #FFFFFF; background-color: #FF69B4 Should be logged/,
] // tslint:disable-line
styleTester("arrow", ">>--[ & ]-->", [], [/>>--\[mad\-logs\.test\.ts\]-->.* Should be logged/]);
styleTester("escherBarbieLego", "||\u2517\u251B\u250F\u2513 & \u250F\u2513\u2517\u251B|| (and various styles)", [], [/\|\|┗┛┏┓ mad\-logs\.test\.ts ┏┓┗┛\|\|.* Should be logged/] // tslint:disable-line
);
styleTester('kingRageBlock', '"(👁‍🗨🗣🗯)" (and various styles)', [
'(👁‍🗨🗣🗯)',
'background-color: purple;',
'color: pink;',
styleTester("kingRageBlock", "\uD83D\uDC41\u200D\uD83D\uDDE8\uD83D\uDDE3\uD83D\uDDEF - and various styles in browser", [
"\uD83D\uDC41\u200D\uD83D\uDDE8 \uD83D\uDDE3 \uD83D\uDDEF ",
"\uD83D\uDC41\u200D\uD83D\uDDE8 \uD83D\uDDE3 \uD83D\uDDEF",
]);
styleTester('mrsPotatoVHS', '(👃👁👂), (👂👁👅), and various styles (including an ultra-thick black border)', ['(👃👁👂)', '(👂👁👅)', "color: black;", "border-style: solid;", "border-width: 5px"]);
styleTester("mrsPotatoVHS", "\uD83D\uDC43 \uD83D\uDC41 \uD83D\uDC42, \uD83D\uDC42 \uD83D\uDC41 \uD83D\uDC45 - & various styles in browser (including ultra-thick black border)", ["\uD83D\uDC43 \uD83D\uDC41 \uD83D\uDC42", "\uD83D\uDC42 \uD83D\uDC41 \uD83D\uDC45"]);
});
describe('shared module', function () {
describe('styles', function () {
testIsoStyle('none');
testIsoStyle('angryBird');
testIsoStyle("aquarium");
testIsoStyle("arrow");
testIsoStyle("backAndForth");
testIsoStyle("barbells");
testIsoStyle("bracelet");
testIsoStyle("brainwave");
testIsoStyle("checkmate");
testIsoStyle("cartoonSwearing");
testIsoStyle("cult");
testIsoStyle("cantTouch");
testIsoStyle("default");
testIsoStyle("dirtRoad");
testIsoStyle("escherBarbieLego");
testIsoStyle("farmerBrown");
testIsoStyle("fresh");
testIsoStyle("grasslands");
testIsoStyle("hatBlock");
testIsoStyle("hotPursuit");
testIsoStyle("joy");
testIsoStyle("kingRageBlock");
testIsoStyle("lakeLouise");
testIsoStyle("lucky");
testIsoStyle("maceWindu");
testIsoStyle("mechanicalAtFists");
testIsoStyle("moProblems");
testIsoStyle("mrsPotatoVHS");
testIsoStyle("neverEnough");
testIsoStyle("ohMy");
testIsoStyle("nightmare");
testIsoStyle("pipeDream");
testIsoStyle("potOfGold");
testIsoStyle("probeArcade");
testIsoStyle("rainbowLeaf");
testIsoStyle("rockIsDead");
testIsoStyle("seafoamSalad");
testIsoStyle("smokeyHatesChristmas");
testIsoStyle("springy");
testIsoStyle("swimmers");
testIsoStyle("tangerines");
testIsoStyle("theBird");
testIsoStyle("theHeist");
testIsoStyle("vendetta");
testIsoStyle("xmlHell");
testIsoStyle("zebra");
});
/****************************************** VISUAL TESTS ******************************************/
describe("Isomorphic styles (visual tests of output in Node)", function () {
visualTestIsoStyle("none");
visualTestIsoStyle("angryBird");
visualTestIsoStyle("aquarium");
visualTestIsoStyle("arrow");
visualTestIsoStyle("backAndForth");
visualTestIsoStyle("barbells");
visualTestIsoStyle("bracelet");
visualTestIsoStyle("brainwave");
visualTestIsoStyle("checkmate");
visualTestIsoStyle("cartoonSwearing");
visualTestIsoStyle("cult");
visualTestIsoStyle("cantTouch");
visualTestIsoStyle("default");
visualTestIsoStyle("dirtRoad");
visualTestIsoStyle("escherBarbieLego");
visualTestIsoStyle("farmerBrown");
visualTestIsoStyle("fountain");
visualTestIsoStyle("fresh");
visualTestIsoStyle("grasslands");
visualTestIsoStyle("hatBlock");
visualTestIsoStyle("hotPursuit");
visualTestIsoStyle("joy");
visualTestIsoStyle("kingRageBlock");
visualTestIsoStyle("lakeLouise");
visualTestIsoStyle("lucky");
visualTestIsoStyle("maceWindu");
visualTestIsoStyle("mechanicalAtFists");
visualTestIsoStyle("moProblems");
visualTestIsoStyle("mrsPotatoVHS");
visualTestIsoStyle("neverEnough");
visualTestIsoStyle("ohMy");
visualTestIsoStyle("nightmare");
visualTestIsoStyle("pipeDream");
visualTestIsoStyle("potOfGold");
visualTestIsoStyle("probeArcade");
visualTestIsoStyle("rainbowLeaf");
visualTestIsoStyle("rockIsDead");
visualTestIsoStyle("seafoamSalad");
visualTestIsoStyle("smokeyHatesChristmas");
visualTestIsoStyle("springy");
visualTestIsoStyle("swimmers");
visualTestIsoStyle("tangerines");
visualTestIsoStyle("theBird");
visualTestIsoStyle("theHeist");
visualTestIsoStyle("vendetta");
visualTestIsoStyle("xmlHell");
visualTestIsoStyle("zebra");
});
//# sourceMappingURL=mad-logs.test.js.map
{
"name": "mad-logs",
"version": "10.3.6",
"version": "11.0.0",
"description": "Winston-lite-esque Log lib for terminal and browser debugging, with piles of unignorable log tags and marker styles.",

@@ -17,3 +17,3 @@ "main": "lib/index.js",

"HACK:fix-lodash": "tir node_modules/@types/lodash/index.d.ts --replace \"interface WeakMap\" \"// interface WeakMap\" >/dev/null",
"repl": "ts-node ./mad-logs-repl.ts",
"repl": "ts-node ./script/mad-logs-repl.ts",
"start": "npm run HACK:fix-lodash 2>/dev/null; LOG_LEVEL=silly npm run test-watch",

@@ -25,3 +25,3 @@ "test": "LOG_LEVEL=silly npm run compile-ts; LOG_LEVEL=silly mocha test/",

"type": "git",
"url": "git+https://github.com/andfaulkner/mad-logs.git#v10.3.6"
"url": "git+https://github.com/andfaulkner/mad-logs.git#v11.0.0"
},

@@ -51,3 +51,3 @@ "keywords": [

"detect-node": "^2.0.3",
"env-var-helpers": "^5.0.1",
"env-var-helpers": "^5.1.0",
"global": "^4.3.1",

@@ -69,3 +69,3 @@ "string.prototype.padend": "^3.0.0"

"lodash": "^4.17.10",
"mad-utils": "^0.72.1",
"mad-utils": "^0.78.1",
"mocha": "^5.2.0",

@@ -72,0 +72,0 @@ "nodemon": "^1.17.5",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet