Update log format, remove timestamp and use file "mcopy.log" in mcopy dir, not mcopy-cli.
This commit is contained in:
parent
099cd3052a
commit
478799965e
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const { createLogger, format, transports } = require('winston');
|
const { createLogger, format, transports } = require('winston');
|
||||||
const { combine, timestamp, label, colorize, simple } = format;
|
const { combine, timestamp, label, colorize, simple, json } = format;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
@ -14,9 +14,9 @@ let transport;
|
||||||
**/
|
**/
|
||||||
async function logFile() {
|
async function logFile() {
|
||||||
const homeDir = os.homedir();
|
const homeDir = os.homedir();
|
||||||
const linuxDir = `/.config/mcopy-cli/`;
|
const linuxDir = `/.config/mcopy/`;
|
||||||
const macDir = `/Library/Logs/mcopy-cli/`;
|
const macDir = `/Library/Logs/mcopy/`;
|
||||||
const winDir = `/AppData/Roaming/mcopy-cli/`;
|
const winDir = `/AppData/Roaming/mcopy/`;
|
||||||
let logPath = path.join(homeDir, linuxDir);
|
let logPath = path.join(homeDir, linuxDir);
|
||||||
let exists;
|
let exists;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
|
@ -29,7 +29,7 @@ async function logFile() {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
await fs.mkdir(logPath);
|
await fs.mkdir(logPath);
|
||||||
}
|
}
|
||||||
return path.join(logPath, 'mcopy-cli.log');
|
return path.join(logPath, 'mcopy.log');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create and return the logger transport based on settings determined in
|
* Create and return the logger transport based on settings determined in
|
||||||
|
@ -50,10 +50,14 @@ module.exports = async function (arg) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (arg && arg.label) {
|
if (arg && arg.label) {
|
||||||
format = combine(label({ label: arg.label }), timestamp(), colorize(), simple());
|
format = combine(label({ label: arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
colorize(), simple());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
format = combine(timestamp(), colorize(), simple());
|
format = combine(
|
||||||
|
//timestamp(),
|
||||||
|
colorize(), simple());
|
||||||
}
|
}
|
||||||
transport = createLogger({
|
transport = createLogger({
|
||||||
transports: [
|
transports: [
|
||||||
|
@ -61,7 +65,10 @@ module.exports = async function (arg) {
|
||||||
format
|
format
|
||||||
}),
|
}),
|
||||||
new (transports.File)({
|
new (transports.File)({
|
||||||
filename: await logFile()
|
filename: await logFile(),
|
||||||
|
format: combine(label({ label: arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
json())
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AAC9D,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,OAA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,SAAS,CAAA;AACjB,CAAC,CAAA"}
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const { createLogger, format, transports } = require('winston');
|
const { createLogger, format, transports } = require('winston');
|
||||||
const { combine, timestamp, label, colorize, simple } = format;
|
const { combine, timestamp, label, colorize, simple, json } = format;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
@ -14,9 +14,9 @@ let transport;
|
||||||
**/
|
**/
|
||||||
async function logFile() {
|
async function logFile() {
|
||||||
const homeDir = os.homedir();
|
const homeDir = os.homedir();
|
||||||
const linuxDir = `/.config/mcopy-cli/`;
|
const linuxDir = `/.config/mcopy/`;
|
||||||
const macDir = `/Library/Logs/mcopy-cli/`;
|
const macDir = `/Library/Logs/mcopy/`;
|
||||||
const winDir = `/AppData/Roaming/mcopy-cli/`;
|
const winDir = `/AppData/Roaming/mcopy/`;
|
||||||
let logPath = path.join(homeDir, linuxDir);
|
let logPath = path.join(homeDir, linuxDir);
|
||||||
let exists;
|
let exists;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
|
@ -29,7 +29,7 @@ async function logFile() {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
await fs.mkdir(logPath);
|
await fs.mkdir(logPath);
|
||||||
}
|
}
|
||||||
return path.join(logPath, 'mcopy-cli.log');
|
return path.join(logPath, 'mcopy.log');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create and return the logger transport based on settings determined in
|
* Create and return the logger transport based on settings determined in
|
||||||
|
@ -50,10 +50,14 @@ module.exports = async function (arg) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (arg && arg.label) {
|
if (arg && arg.label) {
|
||||||
format = combine(label({ label: arg.label }), timestamp(), colorize(), simple());
|
format = combine(label({ label: arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
colorize(), simple());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
format = combine(timestamp(), colorize(), simple());
|
format = combine(
|
||||||
|
//timestamp(),
|
||||||
|
colorize(), simple());
|
||||||
}
|
}
|
||||||
transport = createLogger({
|
transport = createLogger({
|
||||||
transports: [
|
transports: [
|
||||||
|
@ -61,7 +65,10 @@ module.exports = async function (arg) {
|
||||||
format
|
format
|
||||||
}),
|
}),
|
||||||
new (transports.File)({
|
new (transports.File)({
|
||||||
filename: await logFile()
|
filename: await logFile(),
|
||||||
|
format: combine(label({ label: arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
json())
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const { createLogger, format, transports } = require('winston');
|
const { createLogger, format, transports } = require('winston');
|
||||||
const { combine, timestamp, label, colorize, simple } = format;
|
const { combine, timestamp, label, colorize, simple, json } = format;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
@ -14,9 +14,9 @@ let transport;
|
||||||
**/
|
**/
|
||||||
async function logFile() {
|
async function logFile() {
|
||||||
const homeDir = os.homedir();
|
const homeDir = os.homedir();
|
||||||
const linuxDir = `/.config/mcopy-cli/`;
|
const linuxDir = `/.config/mcopy/`;
|
||||||
const macDir = `/Library/Logs/mcopy-cli/`;
|
const macDir = `/Library/Logs/mcopy/`;
|
||||||
const winDir = `/AppData/Roaming/mcopy-cli/`;
|
const winDir = `/AppData/Roaming/mcopy/`;
|
||||||
let logPath = path.join(homeDir, linuxDir);
|
let logPath = path.join(homeDir, linuxDir);
|
||||||
let exists;
|
let exists;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
|
@ -29,7 +29,7 @@ async function logFile() {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
await fs.mkdir(logPath);
|
await fs.mkdir(logPath);
|
||||||
}
|
}
|
||||||
return path.join(logPath, 'mcopy-cli.log');
|
return path.join(logPath, 'mcopy.log');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create and return the logger transport based on settings determined in
|
* Create and return the logger transport based on settings determined in
|
||||||
|
@ -50,10 +50,14 @@ module.exports = async function (arg) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (arg && arg.label) {
|
if (arg && arg.label) {
|
||||||
format = combine(label({ label: arg.label }), timestamp(), colorize(), simple());
|
format = combine(label({ label: arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
colorize(), simple());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
format = combine(timestamp(), colorize(), simple());
|
format = combine(
|
||||||
|
//timestamp(),
|
||||||
|
colorize(), simple());
|
||||||
}
|
}
|
||||||
transport = createLogger({
|
transport = createLogger({
|
||||||
transports: [
|
transports: [
|
||||||
|
@ -61,7 +65,10 @@ module.exports = async function (arg) {
|
||||||
format
|
format
|
||||||
}),
|
}),
|
||||||
new (transports.File)({
|
new (transports.File)({
|
||||||
filename: await logFile()
|
filename: await logFile(),
|
||||||
|
format: combine(label({ label: arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
json())
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const { createLogger, format, transports } = require('winston')
|
const { createLogger, format, transports } = require('winston')
|
||||||
const { combine, timestamp, label, colorize, simple } = format
|
const { combine, timestamp, label, colorize, simple, json } = format
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
@ -18,9 +18,9 @@ let transport : any
|
||||||
async function logFile () {
|
async function logFile () {
|
||||||
|
|
||||||
const homeDir : string = os.homedir();
|
const homeDir : string = os.homedir();
|
||||||
const linuxDir : string = `/.config/mcopy-cli/`;
|
const linuxDir : string = `/.config/mcopy/`;
|
||||||
const macDir : string = `/Library/Logs/mcopy-cli/`;
|
const macDir : string = `/Library/Logs/mcopy/`;
|
||||||
const winDir : string = `/AppData/Roaming/mcopy-cli/`;
|
const winDir : string = `/AppData/Roaming/mcopy/`;
|
||||||
let logPath : string = path.join(homeDir, linuxDir);
|
let logPath : string = path.join(homeDir, linuxDir);
|
||||||
let exists : boolean;
|
let exists : boolean;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ async function logFile () {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
await fs.mkdir(logPath);
|
await fs.mkdir(logPath);
|
||||||
}
|
}
|
||||||
return path.join(logPath, 'mcopy-cli.log');
|
return path.join(logPath, 'mcopy.log');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create and return the logger transport based on settings determined in
|
* Create and return the logger transport based on settings determined in
|
||||||
|
@ -55,13 +55,13 @@ module.exports = async function (arg : any) {
|
||||||
if (arg && arg.label) {
|
if (arg && arg.label) {
|
||||||
format = combine(
|
format = combine(
|
||||||
label({ label : arg.label }),
|
label({ label : arg.label }),
|
||||||
timestamp(),
|
//timestamp(),
|
||||||
colorize(),
|
colorize(),
|
||||||
simple()
|
simple()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
format = combine(
|
format = combine(
|
||||||
timestamp(),
|
//timestamp(),
|
||||||
colorize(),
|
colorize(),
|
||||||
simple()
|
simple()
|
||||||
);
|
);
|
||||||
|
@ -72,7 +72,12 @@ module.exports = async function (arg : any) {
|
||||||
format
|
format
|
||||||
}),
|
}),
|
||||||
new (transports.File)({
|
new (transports.File)({
|
||||||
filename: await logFile()
|
filename: await logFile(),
|
||||||
|
format : combine(
|
||||||
|
label({ label : arg.label }),
|
||||||
|
//timestamp(),
|
||||||
|
json()
|
||||||
|
)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue