Downgrade winston from 3 to 2 because it prints better in the console. Change all require statements to imports, requiring only what's used.
This commit is contained in:
parent
2ff98a2148
commit
1b83fe6937
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
const { createLogger, format, transports } = require('winston');
|
||||
const { combine, timestamp, label, colorize, simple, json } = format;
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const winston_1 = require("winston");
|
||||
const path_1 = require("path");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const os_1 = require("os");
|
||||
const logTime = 'MM/DD/YY-HH:mm:ss';
|
||||
let transport;
|
||||
/**
|
||||
|
@ -13,23 +13,23 @@ let transport;
|
|||
* @returns {string} Path to log file
|
||||
**/
|
||||
async function logFile() {
|
||||
const homeDir = os.homedir();
|
||||
const homeDir = os_1.homedir();
|
||||
const linuxDir = `/.config/mcopy/`;
|
||||
const macDir = `/Library/Logs/mcopy/`;
|
||||
const winDir = `/AppData/Roaming/mcopy/`;
|
||||
let logPath = path.join(homeDir, linuxDir);
|
||||
let exists;
|
||||
let logPath = path_1.join(homeDir, linuxDir);
|
||||
let dirExists;
|
||||
if (process.platform === 'darwin') {
|
||||
logPath = path.join(homeDir, macDir);
|
||||
logPath = path_1.join(homeDir, macDir);
|
||||
}
|
||||
else if (process.platform === 'win32') {
|
||||
logPath = path.join(homeDir, winDir);
|
||||
logPath = path_1.join(homeDir, winDir);
|
||||
}
|
||||
exists = await fs.exists(logPath);
|
||||
if (!exists) {
|
||||
await fs.mkdir(logPath);
|
||||
dirExists = await fs_extra_1.exists(logPath);
|
||||
if (!dirExists) {
|
||||
await fs_extra_1.mkdir(logPath);
|
||||
}
|
||||
return path.join(logPath, 'mcopy.log');
|
||||
return path_1.join(logPath, 'mcopy.log');
|
||||
}
|
||||
/**
|
||||
* Create and return the logger transport based on settings determined in
|
||||
|
@ -40,7 +40,13 @@ async function logFile() {
|
|||
* @returns {object} Logger transport
|
||||
**/
|
||||
module.exports = async function (arg) {
|
||||
let format;
|
||||
let consoleFormat = {
|
||||
colorize: true
|
||||
};
|
||||
let fileFormat = {
|
||||
filename: await logFile(),
|
||||
json: true
|
||||
};
|
||||
if (arg && arg.quiet) {
|
||||
transport = {
|
||||
info: function () { return false; },
|
||||
|
@ -50,26 +56,13 @@ module.exports = async function (arg) {
|
|||
}
|
||||
else {
|
||||
if (arg && arg.label) {
|
||||
format = combine(label({ label: arg.label }),
|
||||
//timestamp(),
|
||||
colorize(), simple());
|
||||
consoleFormat.label = arg.label;
|
||||
fileFormat.label = arg.label;
|
||||
}
|
||||
else {
|
||||
format = combine(
|
||||
//timestamp(),
|
||||
colorize(), simple());
|
||||
}
|
||||
transport = createLogger({
|
||||
transport = new (winston_1.Logger)({
|
||||
transports: [
|
||||
new (transports.Console)({
|
||||
format
|
||||
}),
|
||||
new (transports.File)({
|
||||
filename: await logFile(),
|
||||
format: combine(label({ label: arg.label }),
|
||||
//timestamp(),
|
||||
json())
|
||||
})
|
||||
new (winston_1.transports.Console)(consoleFormat),
|
||||
new (winston_1.transports.File)(fileFormat)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,IAAI,EAAE,GAAG,MAAM,CAAA;AACpE,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,C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ACjB,CAAC,CAAA"}
|
|
@ -7,8 +7,6 @@ process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
|||
|
||||
const electron = require('electron')
|
||||
const { Menu, MenuItem, ipcMain, BrowserWindow, app } = electron
|
||||
const { createLogger, format, transports } = require('winston')
|
||||
const { combine, timestamp, label, printf, colorize, prettyPrint, simple } = format
|
||||
const { EventEmitter } = require('events')
|
||||
const { join } = require('path')
|
||||
|
||||
|
|
|
@ -570,12 +570,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"async": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz",
|
||||
"integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.11"
|
||||
}
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz",
|
||||
"integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k="
|
||||
},
|
||||
"async-done": {
|
||||
"version": "1.3.2",
|
||||
|
@ -1172,15 +1169,6 @@
|
|||
"object-visit": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"color": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz",
|
||||
"integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==",
|
||||
"requires": {
|
||||
"color-convert": "^1.9.1",
|
||||
"color-string": "^1.5.2"
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
|
@ -1209,24 +1197,11 @@
|
|||
"integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
|
||||
"dev": true
|
||||
},
|
||||
"colornames": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz",
|
||||
"integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y="
|
||||
},
|
||||
"colors": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz",
|
||||
"integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg=="
|
||||
},
|
||||
"colorspace": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.1.tgz",
|
||||
"integrity": "sha512-pI3btWyiuz7Ken0BWh9Elzsmv2bM9AhA7psXib4anUXy/orfZ/E0MbQwhSOG/9L8hLlalqrU0UhOuqxW1YjmVw==",
|
||||
"requires": {
|
||||
"color": "3.0.x",
|
||||
"text-hex": "1.0.x"
|
||||
}
|
||||
"integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==",
|
||||
"dev": true
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.7",
|
||||
|
@ -1387,6 +1362,11 @@
|
|||
"array-find-index": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"cycle": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
|
||||
"integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI="
|
||||
},
|
||||
"d": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||
|
@ -1572,16 +1552,6 @@
|
|||
"devices": {
|
||||
"version": "file:lib/devices"
|
||||
},
|
||||
"diagnostics": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz",
|
||||
"integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==",
|
||||
"requires": {
|
||||
"colorspace": "1.1.x",
|
||||
"enabled": "1.0.x",
|
||||
"kuler": "1.0.x"
|
||||
}
|
||||
},
|
||||
"diff": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
|
||||
|
@ -2066,14 +2036,6 @@
|
|||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
|
||||
"integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA=="
|
||||
},
|
||||
"enabled": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz",
|
||||
"integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=",
|
||||
"requires": {
|
||||
"env-variable": "0.0.x"
|
||||
}
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
|
||||
|
@ -2088,11 +2050,6 @@
|
|||
"integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=",
|
||||
"dev": true
|
||||
},
|
||||
"env-variable": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz",
|
||||
"integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA=="
|
||||
},
|
||||
"errno": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
|
||||
|
@ -2431,6 +2388,11 @@
|
|||
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
|
||||
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
|
||||
},
|
||||
"eyes": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
|
||||
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
|
||||
},
|
||||
"fancy-log": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz",
|
||||
|
@ -2453,11 +2415,6 @@
|
|||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"fast-safe-stringify": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz",
|
||||
"integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg=="
|
||||
},
|
||||
"fd-slicer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
|
||||
|
@ -2467,11 +2424,6 @@
|
|||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"fecha": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz",
|
||||
"integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg=="
|
||||
},
|
||||
"ffmpeg": {
|
||||
"version": "file:lib/ffmpeg"
|
||||
},
|
||||
|
@ -4667,14 +4619,6 @@
|
|||
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
|
||||
"dev": true
|
||||
},
|
||||
"kuler": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz",
|
||||
"integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==",
|
||||
"requires": {
|
||||
"colornames": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"last-run": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz",
|
||||
|
@ -4915,18 +4859,6 @@
|
|||
"chalk": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"logform": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/logform/-/logform-2.1.2.tgz",
|
||||
"integrity": "sha512-+lZh4OpERDBLqjiwDLpAWNQu6KMjnlXH2ByZwCuSqVPJletw0kTWJf5CgSNAUKn1KUkv3m2cUz/LK8zyEy7wzQ==",
|
||||
"requires": {
|
||||
"colors": "^1.2.1",
|
||||
"fast-safe-stringify": "^2.0.4",
|
||||
"fecha": "^2.3.3",
|
||||
"ms": "^2.1.1",
|
||||
"triple-beam": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"longest": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
|
||||
|
@ -5746,11 +5678,6 @@
|
|||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"one-time": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz",
|
||||
"integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4="
|
||||
},
|
||||
"onetime": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
|
||||
|
@ -7386,11 +7313,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"text-hex": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
||||
"integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
|
||||
},
|
||||
"throttleit": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz",
|
||||
|
@ -7659,11 +7581,6 @@
|
|||
"integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=",
|
||||
"dev": true
|
||||
},
|
||||
"triple-beam": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
|
||||
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
|
||||
},
|
||||
"truncate-utf8-bytes": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz",
|
||||
|
@ -8151,76 +8068,22 @@
|
|||
"dev": true
|
||||
},
|
||||
"winston": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz",
|
||||
"integrity": "sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw==",
|
||||
"version": "2.4.4",
|
||||
"resolved": "https://registry.npmjs.org/winston/-/winston-2.4.4.tgz",
|
||||
"integrity": "sha512-NBo2Pepn4hK4V01UfcWcDlmiVTs7VTB1h7bgnB0rgP146bYhMxX0ypCz3lBOfNxCO4Zuek7yeT+y/zM1OfMw4Q==",
|
||||
"requires": {
|
||||
"async": "^2.6.1",
|
||||
"diagnostics": "^1.1.1",
|
||||
"is-stream": "^1.1.0",
|
||||
"logform": "^2.1.1",
|
||||
"one-time": "0.0.4",
|
||||
"readable-stream": "^3.1.1",
|
||||
"stack-trace": "0.0.x",
|
||||
"triple-beam": "^1.3.0",
|
||||
"winston-transport": "^4.3.0"
|
||||
"async": "~1.0.0",
|
||||
"colors": "1.0.x",
|
||||
"cycle": "1.0.x",
|
||||
"eyes": "0.1.x",
|
||||
"isstream": "0.1.x",
|
||||
"stack-trace": "0.0.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"readable-stream": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz",
|
||||
"integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==",
|
||||
"requires": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz",
|
||||
"integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"winston-transport": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.3.0.tgz",
|
||||
"integrity": "sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A==",
|
||||
"requires": {
|
||||
"readable-stream": "^2.3.6",
|
||||
"triple-beam": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
"colors": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
|
||||
"integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
"spawn": "file:lib/spawn",
|
||||
"system": "file:lib/system",
|
||||
"uuid": "^3.3.2",
|
||||
"winston": "^3.2.1"
|
||||
"winston": "^2.4.4"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron-installer-debian": "^2.0.0"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
const { createLogger, format, transports } = require('winston');
|
||||
const { combine, timestamp, label, colorize, simple, json } = format;
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const winston_1 = require("winston");
|
||||
const path_1 = require("path");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const os_1 = require("os");
|
||||
const logTime = 'MM/DD/YY-HH:mm:ss';
|
||||
let transport;
|
||||
/**
|
||||
|
@ -13,23 +13,23 @@ let transport;
|
|||
* @returns {string} Path to log file
|
||||
**/
|
||||
async function logFile() {
|
||||
const homeDir = os.homedir();
|
||||
const homeDir = os_1.homedir();
|
||||
const linuxDir = `/.config/mcopy/`;
|
||||
const macDir = `/Library/Logs/mcopy/`;
|
||||
const winDir = `/AppData/Roaming/mcopy/`;
|
||||
let logPath = path.join(homeDir, linuxDir);
|
||||
let exists;
|
||||
let logPath = path_1.join(homeDir, linuxDir);
|
||||
let dirExists;
|
||||
if (process.platform === 'darwin') {
|
||||
logPath = path.join(homeDir, macDir);
|
||||
logPath = path_1.join(homeDir, macDir);
|
||||
}
|
||||
else if (process.platform === 'win32') {
|
||||
logPath = path.join(homeDir, winDir);
|
||||
logPath = path_1.join(homeDir, winDir);
|
||||
}
|
||||
exists = await fs.exists(logPath);
|
||||
if (!exists) {
|
||||
await fs.mkdir(logPath);
|
||||
dirExists = await fs_extra_1.exists(logPath);
|
||||
if (!dirExists) {
|
||||
await fs_extra_1.mkdir(logPath);
|
||||
}
|
||||
return path.join(logPath, 'mcopy.log');
|
||||
return path_1.join(logPath, 'mcopy.log');
|
||||
}
|
||||
/**
|
||||
* Create and return the logger transport based on settings determined in
|
||||
|
@ -40,7 +40,13 @@ async function logFile() {
|
|||
* @returns {object} Logger transport
|
||||
**/
|
||||
module.exports = async function (arg) {
|
||||
let format;
|
||||
let consoleFormat = {
|
||||
colorize: true
|
||||
};
|
||||
let fileFormat = {
|
||||
filename: await logFile(),
|
||||
json: true
|
||||
};
|
||||
if (arg && arg.quiet) {
|
||||
transport = {
|
||||
info: function () { return false; },
|
||||
|
@ -50,26 +56,13 @@ module.exports = async function (arg) {
|
|||
}
|
||||
else {
|
||||
if (arg && arg.label) {
|
||||
format = combine(label({ label: arg.label }),
|
||||
//timestamp(),
|
||||
colorize(), simple());
|
||||
consoleFormat.label = arg.label;
|
||||
fileFormat.label = arg.label;
|
||||
}
|
||||
else {
|
||||
format = combine(
|
||||
//timestamp(),
|
||||
colorize(), simple());
|
||||
}
|
||||
transport = createLogger({
|
||||
transport = new (winston_1.Logger)({
|
||||
transports: [
|
||||
new (transports.Console)({
|
||||
format
|
||||
}),
|
||||
new (transports.File)({
|
||||
filename: await logFile(),
|
||||
format: combine(label({ label: arg.label }),
|
||||
//timestamp(),
|
||||
json())
|
||||
})
|
||||
new (winston_1.transports.Console)(consoleFormat),
|
||||
new (winston_1.transports.File)(fileFormat)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,IAAI,EAAE,GAAG,MAAM,CAAA;AACpE,MAAM,IAAI,GAAG,OAAO,CA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I,CAAC,oBAAU,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;gBACvC,IAAI,CAAC,oBAAU,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;aACjC;SACD,CAAC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA"}
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
const { createLogger, format, transports } = require('winston');
|
||||
const { combine, timestamp, label, colorize, simple, json } = format;
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const winston_1 = require("winston");
|
||||
const path_1 = require("path");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const os_1 = require("os");
|
||||
const logTime = 'MM/DD/YY-HH:mm:ss';
|
||||
let transport;
|
||||
/**
|
||||
|
@ -13,23 +13,23 @@ let transport;
|
|||
* @returns {string} Path to log file
|
||||
**/
|
||||
async function logFile() {
|
||||
const homeDir = os.homedir();
|
||||
const homeDir = os_1.homedir();
|
||||
const linuxDir = `/.config/mcopy/`;
|
||||
const macDir = `/Library/Logs/mcopy/`;
|
||||
const winDir = `/AppData/Roaming/mcopy/`;
|
||||
let logPath = path.join(homeDir, linuxDir);
|
||||
let exists;
|
||||
let logPath = path_1.join(homeDir, linuxDir);
|
||||
let dirExists;
|
||||
if (process.platform === 'darwin') {
|
||||
logPath = path.join(homeDir, macDir);
|
||||
logPath = path_1.join(homeDir, macDir);
|
||||
}
|
||||
else if (process.platform === 'win32') {
|
||||
logPath = path.join(homeDir, winDir);
|
||||
logPath = path_1.join(homeDir, winDir);
|
||||
}
|
||||
exists = await fs.exists(logPath);
|
||||
if (!exists) {
|
||||
await fs.mkdir(logPath);
|
||||
dirExists = await fs_extra_1.exists(logPath);
|
||||
if (!dirExists) {
|
||||
await fs_extra_1.mkdir(logPath);
|
||||
}
|
||||
return path.join(logPath, 'mcopy.log');
|
||||
return path_1.join(logPath, 'mcopy.log');
|
||||
}
|
||||
/**
|
||||
* Create and return the logger transport based on settings determined in
|
||||
|
@ -40,7 +40,13 @@ async function logFile() {
|
|||
* @returns {object} Logger transport
|
||||
**/
|
||||
module.exports = async function (arg) {
|
||||
let format;
|
||||
let consoleFormat = {
|
||||
colorize: true
|
||||
};
|
||||
let fileFormat = {
|
||||
filename: await logFile(),
|
||||
json: true
|
||||
};
|
||||
if (arg && arg.quiet) {
|
||||
transport = {
|
||||
info: function () { return false; },
|
||||
|
@ -50,26 +56,13 @@ module.exports = async function (arg) {
|
|||
}
|
||||
else {
|
||||
if (arg && arg.label) {
|
||||
format = combine(label({ label: arg.label }),
|
||||
//timestamp(),
|
||||
colorize(), simple());
|
||||
consoleFormat.label = arg.label;
|
||||
fileFormat.label = arg.label;
|
||||
}
|
||||
else {
|
||||
format = combine(
|
||||
//timestamp(),
|
||||
colorize(), simple());
|
||||
}
|
||||
transport = createLogger({
|
||||
transport = new (winston_1.Logger)({
|
||||
transports: [
|
||||
new (transports.Console)({
|
||||
format
|
||||
}),
|
||||
new (transports.File)({
|
||||
filename: await logFile(),
|
||||
format: combine(label({ label: arg.label }),
|
||||
//timestamp(),
|
||||
json())
|
||||
})
|
||||
new (winston_1.transports.Console)(consoleFormat),
|
||||
new (winston_1.transports.File)(fileFormat)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,IAAI,EAAE,GAAG,MAAM,CAAA;AACpE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CA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AC,oBAAU,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;aACjC;SACD,CAAC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA"}
|
|
@ -10,6 +10,7 @@ declare module 'systeminformation';
|
|||
declare module 'exit';
|
||||
declare module 'request';
|
||||
declare module 'animated-gif-detector';
|
||||
declare module 'winston';
|
||||
|
||||
interface Device {
|
||||
arduino : string;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
'use strict'
|
||||
|
||||
const { createLogger, format, transports } = require('winston')
|
||||
const { combine, timestamp, label, colorize, simple, json } = format
|
||||
const path = require('path')
|
||||
const fs = require('fs-extra')
|
||||
const os = require('os')
|
||||
import { Logger, transports } from 'winston';
|
||||
import { join } from 'path';
|
||||
import { mkdir, exists } from 'fs-extra';
|
||||
import { homedir } from 'os';
|
||||
|
||||
const logTime = 'MM/DD/YY-HH:mm:ss'
|
||||
let transport : any
|
||||
|
@ -16,24 +15,23 @@ let transport : any
|
|||
* @returns {string} Path to log file
|
||||
**/
|
||||
async function logFile () {
|
||||
|
||||
const homeDir : string = os.homedir();
|
||||
const homeDir : string = homedir();
|
||||
const linuxDir : string = `/.config/mcopy/`;
|
||||
const macDir : string = `/Library/Logs/mcopy/`;
|
||||
const winDir : string = `/AppData/Roaming/mcopy/`;
|
||||
let logPath : string = path.join(homeDir, linuxDir);
|
||||
let exists : boolean;
|
||||
let logPath : string = join(homeDir, linuxDir);
|
||||
let dirExists : boolean;
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
logPath = path.join(homeDir, macDir);
|
||||
logPath = join(homeDir, macDir);
|
||||
} else if (process.platform === 'win32') {
|
||||
logPath = path.join(homeDir, winDir);
|
||||
logPath = join(homeDir, winDir);
|
||||
}
|
||||
exists = await fs.exists(logPath);
|
||||
if (!exists) {
|
||||
await fs.mkdir(logPath);
|
||||
dirExists = await exists(logPath);
|
||||
if (!dirExists) {
|
||||
await mkdir(logPath);
|
||||
}
|
||||
return path.join(logPath, 'mcopy.log');
|
||||
return join(logPath, 'mcopy.log');
|
||||
}
|
||||
/**
|
||||
* Create and return the logger transport based on settings determined in
|
||||
|
@ -44,7 +42,13 @@ async function logFile () {
|
|||
* @returns {object} Logger transport
|
||||
**/
|
||||
module.exports = async function (arg : any) {
|
||||
let format;
|
||||
let consoleFormat : any = {
|
||||
colorize : true
|
||||
}
|
||||
let fileFormat : any = {
|
||||
filename : await logFile(),
|
||||
json : true
|
||||
}
|
||||
if (arg && arg.quiet) {
|
||||
transport = {
|
||||
info : function () { return false },
|
||||
|
@ -53,32 +57,13 @@ module.exports = async function (arg : any) {
|
|||
}
|
||||
} else {
|
||||
if (arg && arg.label) {
|
||||
format = combine(
|
||||
label({ label : arg.label }),
|
||||
//timestamp(),
|
||||
colorize(),
|
||||
simple()
|
||||
);
|
||||
} else {
|
||||
format = combine(
|
||||
//timestamp(),
|
||||
colorize(),
|
||||
simple()
|
||||
);
|
||||
consoleFormat.label = arg.label;
|
||||
fileFormat.label = arg.label;
|
||||
}
|
||||
transport = createLogger({
|
||||
transport = new (Logger)({
|
||||
transports: [
|
||||
new (transports.Console)({
|
||||
format
|
||||
}),
|
||||
new (transports.File)({
|
||||
filename: await logFile(),
|
||||
format : combine(
|
||||
label({ label : arg.label }),
|
||||
//timestamp(),
|
||||
json()
|
||||
)
|
||||
})
|
||||
new (transports.Console)(consoleFormat),
|
||||
new (transports.File)(fileFormat)
|
||||
]
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue