Add a label argument to the log module.

This commit is contained in:
mmcwilliams 2019-03-21 15:54:55 -04:00
parent 87d43fc15b
commit c563bf0dd3
7 changed files with 51 additions and 18 deletions

View File

@ -1,6 +1,6 @@
'use strict';
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;
const { combine, timestamp, label, colorize, simple } = format;
const path = require('path');
const fs = require('fs-extra');
const os = require('os');
@ -40,7 +40,8 @@ async function logFile() {
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
if (arg.quiet) {
let format;
if (arg && arg.quiet) {
transport = {
info: function () { },
warn: function () { },
@ -48,10 +49,16 @@ module.exports = async function (arg) {
};
}
else {
if (arg && arg.label) {
format = combine(label({ label: arg.label }), timestamp(), colorize(), simple());
}
else {
format = combine(timestamp(), colorize(), simple());
}
transport = createLogger({
transports: [
new (transports.Console)({
format: combine(format.colorize(), format.simple())
format
}),
new (transports.File)({
filename: await logFile()

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAC/D,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAC9B,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExB,MAAM,OAAO,GAAG,mBAAmB,CAAA;AACnC,IAAI,SAAe,CAAA;AAEnB;;;;;IAKI;AACJ,KAAK,UAAU,OAAO;IAErB,MAAM,OAAO,GAAY,EAAE,CAAC,OAAO,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAY,qBAAqB,CAAC;IAChD,MAAM,MAAM,GAAY,0BA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xB;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAC5C,CAAC;AACD;;;;;;;IAOI;AACJ,MAAM,CAAC,OAAO,GAAG,KAAK,WAAW,GAAS;IACzC,IAAI,MAAM,CAAC;IACX,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE;QACrB,SAAS,GAAG;YACX,IAAI,EAAG,cAAa,CAAC;YACrB,IAAI,EAAG,cAAa,CAAC;YACrB,KAAK,EAAG,cAAa,CAAC;SACtB,CAAA;KACD;SAAM;QACN,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE;YACrB,MAAM,GAAG,OAAO,CACf,KAAK,CAAC,EAAE,KAAK,EAAG,GAAG,CAAC,KAAK,EAAE,CAAC,EAC5B,SAAS,EAAE,EACX,QAAQ,EAAE,EACV,MAAM,EAAE,CACR,CAAC;SACF;aAAM;YACN,MAAM,GAAG,OAAO,CACf,SAAS,EAAE,EACX,QAAQ,EAAE,EACV,MAAM,EAAE,CACR,CAAC;SACF;QACD,SAAS,GAAG,YAAY,CAAC;YACxB,UAAU,EAAE;gBACX,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACxB,MAAM;iBACN,CAAC;gBACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBACrB,QAAQ,EAAE,MAAM,OAAO,EAAE;iBACzB,CAAC;aACF;SACD,CAAC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA"}

View File

@ -1,6 +1,6 @@
'use strict';
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;
const { combine, timestamp, label, colorize, simple } = format;
const path = require('path');
const fs = require('fs-extra');
const os = require('os');
@ -40,7 +40,8 @@ async function logFile() {
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
if (arg.quiet) {
let format;
if (arg && arg.quiet) {
transport = {
info: function () { },
warn: function () { },
@ -48,10 +49,16 @@ module.exports = async function (arg) {
};
}
else {
if (arg && arg.label) {
format = combine(label({ label: arg.label }), timestamp(), colorize(), simple());
}
else {
format = combine(timestamp(), colorize(), simple());
}
transport = createLogger({
transports: [
new (transports.Console)({
format: combine(format.colorize(), format.simple())
format
}),
new (transports.File)({
filename: await logFile()

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAC/D,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAC9B,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExB,MAAM,OAAO,GAAG,mBAAmB,CAAA;AACnC,IAAI,SAAe,CAAA;AAEnB;;;;;IAKI;AACJ,KAAK,UAAU,OAAO;IAErB,MAAM,OAAO,GAAY,EAAE,CAAC,OAAO,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAY,qBAAqB,CAAC;IAChD,MAAM,MAAM,GAAY,0BAA0B,CAAC;IACnD,MAAM,MAAM,GAAY,6BAA6B,CAAC;IACtD,IAAI,OAAO,GAAY,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpD,IAAI,MAAgB,CAAC;IAErB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;QAClC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KACrC;SAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;QACxC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC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ACrB,MAAM,GAAG,OAAO,CACf,KAAK,CAAC,EAAE,KAAK,EAAG,GAAG,CAAC,KAAK,EAAE,CAAC,EAC5B,SAAS,EAAE,EACX,QAAQ,EAAE,EACV,MAAM,EAAE,CACR,CAAC;SACF;aAAM;YACN,MAAM,GAAG,OAAO,CACf,SAAS,EAAE,EACX,QAAQ,EAAE,EACV,MAAM,EAAE,CACR,CAAC;SACF;QACD,SAAS,GAAG,YAAY,CAAC;YACxB,UAAU,EAAE;gBACX,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACxB,MAAM;iBACN,CAAC;gBACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBACrB,QAAQ,EAAE,MAAM,OAAO,EAAE;iBACzB,CAAC;aACF;SACD,CAAC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA"}

View File

@ -1,6 +1,6 @@
'use strict';
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;
const { combine, timestamp, label, colorize, simple } = format;
const path = require('path');
const fs = require('fs-extra');
const os = require('os');
@ -40,7 +40,8 @@ async function logFile() {
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
if (arg.quiet) {
let format;
if (arg && arg.quiet) {
transport = {
info: function () { },
warn: function () { },
@ -48,10 +49,16 @@ module.exports = async function (arg) {
};
}
else {
if (arg && arg.label) {
format = combine(label({ label: arg.label }), timestamp(), colorize(), simple());
}
else {
format = combine(timestamp(), colorize(), simple());
}
transport = createLogger({
transports: [
new (transports.Console)({
format: combine(format.colorize(), format.simple())
format
}),
new (transports.File)({
filename: await logFile()

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAC/D,MAAM,EAAE,OAAO,EAAE,SAAS,E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,CAAC,IAAI,CAAC,CAAC;oBACrB,QAAQ,EAAE,MAAM,OAAO,EAAE;iBACzB,CAAC;aACF;SACD,CAAC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA"}

View File

@ -1,7 +1,7 @@
'use strict'
const { createLogger, format, transports } = require('winston')
const { combine, timestamp, label, printf } = format
const { combine, timestamp, label, colorize, simple } = format
const path = require('path')
const fs = require('fs-extra')
const os = require('os')
@ -44,20 +44,32 @@ async function logFile () {
* @returns {object} Logger transport
**/
module.exports = async function (arg : any) {
if (arg.quiet) {
let format;
if (arg && arg.quiet) {
transport = {
info : function () {},
warn : function () {},
error : function () {}
}
} else {
if (arg && arg.label) {
format = combine(
label({ label : arg.label }),
timestamp(),
colorize(),
simple()
);
} else {
format = combine(
timestamp(),
colorize(),
simple()
);
}
transport = createLogger({
transports: [
new (transports.Console)({
format: combine(
format.colorize(),
format.simple()
)
format
}),
new (transports.File)({
filename: await logFile()