Refactor logFile function for readability.

Add comments to the log library. Build logs.
This commit is contained in:
mmcwilliams 2019-03-18 16:50:40 -04:00
parent 1a31767572
commit 9b4525e5a7
8 changed files with 106 additions and 25 deletions

8
app/lib/log/Readme.md Normal file
View File

@ -0,0 +1,8 @@
<a name="logFile"></a>
## logFile() ⇒ <code>string</code>
Determine the location of the log file based on the operating system
and return as an absolute string from os.homedir()
**Kind**: global function
**Returns**: <code>string</code> - Path to log file

View File

@ -6,14 +6,24 @@ const fs = require('fs-extra');
const os = require('os');
const logTime = 'MM/DD/YY-HH:mm:ss';
let transport;
/**
* Determine the location of the log file based on the operating system
* and return as an absolute string from os.homedir()
*
* @returns {string} Path to log file
**/
async function logFile() {
const homeDir = os.homedir();
const linuxDir = `/.config/mcopy-cli/`;
const macDir = `/Library/Logs/mcopy-cli/`;
const winDir = `/AppData/Roaming/mcopy-cli/`;
let logPath = path.join(homeDir, linuxDir);
let exists;
let logPath = path.join(os.homedir(), `/.config/mcopy-cli/`);
if (process.platform === 'darwin') {
logPath = path.join(os.homedir(), `/Library/Logs/mcopy-cli/`);
logPath = path.join(homeDir, macDir);
}
else if (process.platform === 'win32') {
logPath = path.join(os.homedir(), `/AppData/Roaming/mcopy-cli/`);
logPath = path.join(homeDir, winDir);
}
exists = await fs.exists(logPath);
if (!exists) {
@ -21,6 +31,14 @@ async function logFile() {
}
return path.join(logPath, 'mcopy-cli.log');
}
/**
* Create and return the logger transport based on settings determined in
* arguments object
*
* @param {object} arg Arguments from process
*
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
if (arg.quiet) {
transport = {

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,EAA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Q,KAAK,OAAO,EAAE;QACxC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KACrC;IACD,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE;QACZ,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB;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,GAAG,CAAC,KAAK,EAAE;QACd,SAAS,GAAG;YACX,IAAI,EAAG,cAAa,CAAC;YACrB,IAAI,EAAG,cAAa,CAAC;YACrB,KAAK,EAAG,cAAa,CAAC;SACtB,CAAA;KACD;SAAM;QACN,SAAS,GAAG,YAAY,CAAC;YACxB,UAAU,EAAE;gBACX,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACxB,MAAM,EAAE,OAAO,CACd,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,MAAM,EAAE,CACf;iBACD,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

@ -6,14 +6,24 @@ const fs = require('fs-extra');
const os = require('os');
const logTime = 'MM/DD/YY-HH:mm:ss';
let transport;
/**
* Determine the location of the log file based on the operating system
* and return as an absolute string from os.homedir()
*
* @returns {string} Path to log file
**/
async function logFile() {
const homeDir = os.homedir();
const linuxDir = `/.config/mcopy-cli/`;
const macDir = `/Library/Logs/mcopy-cli/`;
const winDir = `/AppData/Roaming/mcopy-cli/`;
let logPath = path.join(homeDir, linuxDir);
let exists;
let logPath = path.join(os.homedir(), `/.config/mcopy-cli/`);
if (process.platform === 'darwin') {
logPath = path.join(os.homedir(), `/Library/Logs/mcopy-cli/`);
logPath = path.join(homeDir, macDir);
}
else if (process.platform === 'win32') {
logPath = path.join(os.homedir(), `/AppData/Roaming/mcopy-cli/`);
logPath = path.join(homeDir, winDir);
}
exists = await fs.exists(logPath);
if (!exists) {
@ -21,6 +31,14 @@ async function logFile() {
}
return path.join(logPath, 'mcopy-cli.log');
}
/**
* Create and return the logger transport based on settings determined in
* arguments object
*
* @param {object} arg Arguments from process
*
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
if (arg.quiet) {
transport = {

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,KAAK,UAAU,OAAO;IACrB,IAAI,MAAgB,CAAA;IACpB,IAAI,OAAO,GAAY,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,qBAAqB,CAAC,CAAA;IACrE,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;QAClC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,0BAA0B,CAAC,CAAA;KAC7D;SAAM,IAAI,OAAO,CAAC,QAAQ,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G,YAAY,CAAC;YACxB,UAAU,EAAE;gBACX,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACxB,MAAM,EAAE,OAAO,CACd,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,MAAM,EAAE,CACf;iBACD,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

@ -6,14 +6,24 @@ const fs = require('fs-extra');
const os = require('os');
const logTime = 'MM/DD/YY-HH:mm:ss';
let transport;
/**
* Determine the location of the log file based on the operating system
* and return as an absolute string from os.homedir()
*
* @returns {string} Path to log file
**/
async function logFile() {
const homeDir = os.homedir();
const linuxDir = `/.config/mcopy-cli/`;
const macDir = `/Library/Logs/mcopy-cli/`;
const winDir = `/AppData/Roaming/mcopy-cli/`;
let logPath = path.join(homeDir, linuxDir);
let exists;
let logPath = path.join(os.homedir(), `/.config/mcopy-cli/`);
if (process.platform === 'darwin') {
logPath = path.join(os.homedir(), `/Library/Logs/mcopy-cli/`);
logPath = path.join(homeDir, macDir);
}
else if (process.platform === 'win32') {
logPath = path.join(os.homedir(), `/AppData/Roaming/mcopy-cli/`);
logPath = path.join(homeDir, winDir);
}
exists = await fs.exists(logPath);
if (!exists) {
@ -21,6 +31,14 @@ async function logFile() {
}
return path.join(logPath, 'mcopy-cli.log');
}
/**
* Create and return the logger transport based on settings determined in
* arguments object
*
* @param {object} arg Arguments from process
*
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
if (arg.quiet) {
transport = {

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,CA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AAI,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,CAAC;KACrC;IACD,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE;QACZ,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB;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,GAAG,CAAC,KAAK,EAAE;QACd,SAAS,GAAG;YACX,IAAI,EAAG,cAAa,CAAC;YACrB,IAAI,EAAG,cAAa,CAAC;YACrB,KAAK,EAAG,cAAa,CAAC;SACtB,CAAA;KACD;SAAM;QACN,SAAS,GAAG,YAAY,CAAC;YACxB,UAAU,EAAE;gBACX,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACxB,MAAM,EAAE,OAAO,CACd,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,MAAM,EAAE,CACf;iBACD,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

@ -9,21 +9,40 @@ const os = require('os')
const logTime = 'MM/DD/YY-HH:mm:ss'
let transport : any
/**
* Determine the location of the log file based on the operating system
* and return as an absolute string from os.homedir()
*
* @returns {string} Path to log file
**/
async function logFile () {
let exists : boolean
let logPath : string = path.join(os.homedir(), `/.config/mcopy-cli/`)
if (process.platform === 'darwin') {
logPath = path.join(os.homedir(), `/Library/Logs/mcopy-cli/`)
} else if (process.platform === 'win32') {
logPath = path.join(os.homedir(), `/AppData/Roaming/mcopy-cli/`)
}
exists = await fs.exists(logPath)
if (!exists) {
await fs.mkdir(logPath)
}
return path.join(logPath, 'mcopy-cli.log')
}
const homeDir : string = os.homedir();
const linuxDir : string = `/.config/mcopy-cli/`;
const macDir : string = `/Library/Logs/mcopy-cli/`;
const winDir : string = `/AppData/Roaming/mcopy-cli/`;
let logPath : string = path.join(homeDir, linuxDir);
let exists : boolean;
if (process.platform === 'darwin') {
logPath = path.join(homeDir, macDir);
} else if (process.platform === 'win32') {
logPath = path.join(homeDir, winDir);
}
exists = await fs.exists(logPath);
if (!exists) {
await fs.mkdir(logPath);
}
return path.join(logPath, 'mcopy-cli.log');
}
/**
* Create and return the logger transport based on settings determined in
* arguments object
*
* @param {object} arg Arguments from process
*
* @returns {object} Logger transport
**/
module.exports = async function (arg : any) {
if (arg.quiet) {
transport = {