Comparing version 3.2.0 to 3.3.0
@@ -6,8 +6,11 @@ "use strict"; | ||
}); | ||
// super basic browser support just to avoid breaking universal builds. | ||
// Super basic browser support just to avoid breaking universal builds. | ||
// title and log level are not included in the output at this time. | ||
var logger = function logger() { | ||
var _console; | ||
return (_console = console).log.apply(_console, arguments); | ||
}; | ||
function createLogger() /* title */{ | ||
function logger() { | ||
console.log.apply(console, arguments); | ||
} | ||
return { | ||
@@ -14,0 +17,0 @@ info: logger, |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _chalk2 = _interopRequireDefault(_chalk); | ||
var _nicelyFormat = require('nicely-format'); | ||
@@ -29,3 +31,3 @@ | ||
var indentText = function indentText(text) { | ||
return text.replace(/^(?!\s+$)/mg, ' '.repeat(13)).trim(); | ||
return text.replace(/^(?!\s+$)/gm, ' '.repeat(13)).trim(); | ||
}; | ||
@@ -42,2 +44,3 @@ | ||
} | ||
return (0, _nicelyFormat2.default)(message, { | ||
@@ -66,4 +69,6 @@ highlight: true, | ||
}); | ||
}).map(indentText); | ||
logFunction.apply(undefined, [(0, _chalk.gray)(time()), `[${title}]`].concat(_toConsumableArray(formattedMessages))); | ||
}).map(function (text) { | ||
return indentText(text); | ||
}); | ||
logFunction.apply(undefined, [_chalk2.default.gray(time()), `[${title}]`].concat(_toConsumableArray(formattedMessages))); | ||
}; | ||
@@ -85,3 +90,3 @@ | ||
logger({ | ||
title: (0, _chalk.yellow)(`DEBUG ${title}`), | ||
title: _chalk2.default.yellow(`DEBUG ${title}`), | ||
messages, | ||
@@ -97,3 +102,3 @@ logFunction: debugFunction | ||
logger({ | ||
title: (0, _chalk.blue)(title), | ||
title: _chalk2.default.blue(title), | ||
messages, | ||
@@ -109,3 +114,3 @@ logFunction | ||
logger({ | ||
title: (0, _chalk.yellow)(`WARNING ${title}`), | ||
title: _chalk2.default.yellow(`WARNING ${title}`), | ||
messages, | ||
@@ -121,3 +126,3 @@ logFunction | ||
logger({ | ||
title: (0, _chalk.red)(`ERROR ${title}`), | ||
title: _chalk2.default.red(`ERROR ${title}`), | ||
messages, | ||
@@ -133,3 +138,3 @@ logFunction | ||
logger({ | ||
title: (0, _chalk.red)(`========= FATAL ${title} =========`), | ||
title: _chalk2.default.red(`========= FATAL ${title} =========`), | ||
messages, | ||
@@ -145,3 +150,3 @@ logFunction | ||
logger({ | ||
title: (0, _chalk.red)(`TRACE ${title}`), | ||
title: _chalk2.default.red(`TRACE ${title}`), | ||
messages, | ||
@@ -148,0 +153,0 @@ logFunction |
{ | ||
"name": "logging", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Lightweight informative modern console logging.", | ||
@@ -9,3 +9,4 @@ "main": "lib", | ||
"lib", | ||
"src" | ||
"src", | ||
"index.d.ts" | ||
], | ||
@@ -28,8 +29,8 @@ "scripts": { | ||
"dependencies": { | ||
"nicely-format": "^1.1.0", | ||
"chalk": "^1.1.3", | ||
"debug": "^2.6.1" | ||
"chalk": "^4.1.0", | ||
"debug": "^4.3.1", | ||
"nicely-format": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.18.2", | ||
"ava": "^3.15.0", | ||
"babel-cli": "^6.23.0", | ||
@@ -40,17 +41,17 @@ "babel-core": "^6.23.1", | ||
"babel-runtime": "^6.23.0", | ||
"eslint": "^3.16.0", | ||
"eslint-config-xo": "^0.17.0", | ||
"eslint-loader": "^1.6.0", | ||
"eslint-plugin-ava": "^4.2.0", | ||
"eslint": "^7.19.0", | ||
"eslint-config-xo": "^0.34.0", | ||
"eslint-loader": "^4.0.2", | ||
"eslint-plugin-ava": "^11.0.0", | ||
"eslint-plugin-import": "^2.0.1", | ||
"eslint-plugin-no-use-extend-native": "^0.3.11", | ||
"eslint-plugin-promise": "^3.4.2", | ||
"eslint-plugin-unicorn": "^2.0.1", | ||
"husky": "^0.13.1", | ||
"mockdate": "^2.0.1", | ||
"nodemon": "^1.11.0", | ||
"np": "^2.12.0", | ||
"npm": "^4.2.0", | ||
"eslint-plugin-no-use-extend-native": "^0.5.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-unicorn": "^27.0.0", | ||
"husky": "^4.3.8", | ||
"mockdate": "^3.0.2", | ||
"nodemon": "^2.0.7", | ||
"np": "^7.2.0", | ||
"npm": "^7.5.2", | ||
"npm-check": "^5.4.0", | ||
"sinon": "^2.0.0-pre.4" | ||
"sinon": "^9.2.4" | ||
}, | ||
@@ -64,3 +65,6 @@ "engines": { | ||
] | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
} | ||
} |
@@ -1,7 +0,6 @@ | ||
// super basic browser support just to avoid breaking universal builds. | ||
// Super basic browser support just to avoid breaking universal builds. | ||
// title and log level are not included in the output at this time. | ||
const logger = (...arguments_) => console.log(...arguments_); | ||
function createLogger(/* title */) { | ||
function logger() { | ||
console.log.apply(console, arguments); | ||
} | ||
return { | ||
@@ -8,0 +7,0 @@ info: logger, |
@@ -1,7 +0,2 @@ | ||
import { | ||
blue, | ||
yellow, | ||
red, | ||
gray | ||
} from 'chalk'; | ||
import chalk from 'chalk'; | ||
import nicelyFormat from 'nicely-format'; | ||
@@ -16,9 +11,9 @@ import createDebug from 'debug'; | ||
const indentText = (text) => text.replace(/^(?!\s+$)/mg, ' '.repeat(13)).trim(); | ||
const indentText = (text) => text.replace(/^(?!\s+$)/gm, ' '.repeat(13)).trim(); | ||
const logger = ({ | ||
title, | ||
messages, | ||
logFunction | ||
}) => { | ||
title, | ||
messages, | ||
logFunction | ||
}) => { | ||
const formattedMessages = messages.map((message) => { | ||
@@ -28,2 +23,3 @@ if (typeof message === 'string') { | ||
} | ||
return nicelyFormat(message, { | ||
@@ -52,15 +48,15 @@ highlight: true, | ||
}); | ||
}).map(indentText); | ||
logFunction(gray(time()), `[${title}]`, ...formattedMessages); | ||
}).map((text) => indentText(text)); | ||
logFunction(chalk.gray(time()), `[${title}]`, ...formattedMessages); | ||
}; | ||
const createLogger = (title, | ||
{ | ||
debugFunction = createDebug(title), | ||
logFunction = console.log | ||
} = {}) => { | ||
{ | ||
debugFunction = createDebug(title), | ||
logFunction = console.log | ||
} = {}) => { | ||
return { | ||
debug(...messages) { | ||
logger({ | ||
title: yellow(`DEBUG ${title}`), | ||
title: chalk.yellow(`DEBUG ${title}`), | ||
messages, | ||
@@ -72,3 +68,3 @@ logFunction: debugFunction | ||
logger({ | ||
title: blue(title), | ||
title: chalk.blue(title), | ||
messages, | ||
@@ -80,3 +76,3 @@ logFunction | ||
logger({ | ||
title: yellow(`WARNING ${title}`), | ||
title: chalk.yellow(`WARNING ${title}`), | ||
messages, | ||
@@ -88,3 +84,3 @@ logFunction | ||
logger({ | ||
title: red(`ERROR ${title}`), | ||
title: chalk.red(`ERROR ${title}`), | ||
messages, | ||
@@ -96,3 +92,3 @@ logFunction | ||
logger({ | ||
title: red(`========= FATAL ${title} =========`), | ||
title: chalk.red(`========= FATAL ${title} =========`), | ||
messages, | ||
@@ -104,3 +100,3 @@ logFunction | ||
logger({ | ||
title: red(`TRACE ${title}`), | ||
title: chalk.red(`TRACE ${title}`), | ||
messages, | ||
@@ -107,0 +103,0 @@ logFunction |
13151
10
284
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedms@2.0.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedchalk@^4.1.0
Updateddebug@^4.3.1