diginext-utils 2.0.24 → 2.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/console/log.d.ts +12 -12
- package/dist/console/log.js +10 -5
- package/dist/console/log.js.map +1 -1
- package/dist/device/os.d.ts +11 -0
- package/dist/device/os.js +38 -0
- package/dist/device/os.js.map +1 -0
- package/esm/console/log.d.ts +12 -12
- package/esm/console/log.js +10 -5
- package/esm/console/log.js.map +1 -1
- package/esm/device/os.d.ts +11 -0
- package/esm/device/os.js +28 -0
- package/esm/device/os.js.map +1 -0
- package/package.json +1 -1
- package/src/console/log.ts +10 -5
- package/src/device/os.ts +29 -0
package/dist/console/log.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const log: (...msg: any) =>
|
|
2
|
-
export declare const logFull: (data?: {}) =>
|
|
3
|
-
export declare const logRes: (res: any, ...msg: any[]) =>
|
|
4
|
-
export declare const logError: (...msg: any[]) =>
|
|
5
|
-
export declare const logWarn: (...msg: any[]) =>
|
|
6
|
-
export declare const logSuccess: (...msg: any[]) =>
|
|
1
|
+
export declare const log: (...msg: any) => any;
|
|
2
|
+
export declare const logFull: (data?: {}) => {};
|
|
3
|
+
export declare const logRes: (res: any, ...msg: any[]) => any[];
|
|
4
|
+
export declare const logError: (...msg: any[]) => any[];
|
|
5
|
+
export declare const logWarn: (...msg: any[]) => any[];
|
|
6
|
+
export declare const logSuccess: (...msg: any[]) => any[];
|
|
7
7
|
declare const xlog: {
|
|
8
|
-
log: (...msg: any) =>
|
|
9
|
-
logFull: (data?: {}) =>
|
|
10
|
-
logRes: (res: any, ...msg: any[]) =>
|
|
11
|
-
logError: (...msg: any[]) =>
|
|
12
|
-
logWarn: (...msg: any[]) =>
|
|
13
|
-
logSuccess: (...msg: any[]) =>
|
|
8
|
+
log: (...msg: any) => any;
|
|
9
|
+
logFull: (data?: {}) => {};
|
|
10
|
+
logRes: (res: any, ...msg: any[]) => any[];
|
|
11
|
+
logError: (...msg: any[]) => any[];
|
|
12
|
+
logWarn: (...msg: any[]) => any[];
|
|
13
|
+
logSuccess: (...msg: any[]) => any[];
|
|
14
14
|
};
|
|
15
15
|
export default xlog;
|
package/dist/console/log.js
CHANGED
|
@@ -7,11 +7,13 @@ exports.logSuccess = exports.logWarn = exports.logError = exports.logRes = expor
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const log = (...msg) => {
|
|
10
|
-
console.log(chalk_1.default.
|
|
10
|
+
console.log(chalk_1.default.bgBlue.white(`[LOGGING ${(0, dayjs_1.default)().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
11
|
+
return msg;
|
|
11
12
|
};
|
|
12
13
|
exports.log = log;
|
|
13
14
|
const logFull = (data = {}) => {
|
|
14
15
|
console.dir(data, { depth: null, colors: true, maxArrayLength: null });
|
|
16
|
+
return data;
|
|
15
17
|
};
|
|
16
18
|
exports.logFull = logFull;
|
|
17
19
|
const logRes = (res, ...msg) => {
|
|
@@ -19,20 +21,23 @@ const logRes = (res, ...msg) => {
|
|
|
19
21
|
/**
|
|
20
22
|
* res.locals.req = Express Request
|
|
21
23
|
*/
|
|
22
|
-
// console.log(res.locals.req);
|
|
23
24
|
console.warn(chalk_1.default.blue(`[${res.statusCode}] ${((_a = res.locals.req) === null || _a === void 0 ? void 0 : _a.originalUrl) || "UNKNOWN_PATH"} >> ${(_b = res.locals.req) === null || _b === void 0 ? void 0 : _b.method} >>`), ...msg);
|
|
25
|
+
return msg;
|
|
24
26
|
};
|
|
25
27
|
exports.logRes = logRes;
|
|
26
28
|
const logError = (...msg) => {
|
|
27
|
-
console.error(chalk_1.default.bgRed
|
|
29
|
+
console.error(chalk_1.default.bgRed.white(`[ERROR ${(0, dayjs_1.default)().format("YYYY-MM-DD HH:mm:ss")}]`), chalk_1.default.red(...msg));
|
|
30
|
+
return msg;
|
|
28
31
|
};
|
|
29
32
|
exports.logError = logError;
|
|
30
33
|
const logWarn = (...msg) => {
|
|
31
|
-
console.warn(chalk_1.default.
|
|
34
|
+
console.warn(chalk_1.default.bgYellow.black(`[WARNING ${(0, dayjs_1.default)().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
35
|
+
return msg;
|
|
32
36
|
};
|
|
33
37
|
exports.logWarn = logWarn;
|
|
34
38
|
const logSuccess = (...msg) => {
|
|
35
|
-
console.info(chalk_1.default.
|
|
39
|
+
console.info(chalk_1.default.bgGreen.black(`[SUCCESS ${(0, dayjs_1.default)().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
40
|
+
return msg;
|
|
36
41
|
};
|
|
37
42
|
exports.logSuccess = logSuccess;
|
|
38
43
|
const xlog = { log: exports.log, logFull: exports.logFull, logRes: exports.logRes, logError: exports.logError, logWarn: exports.logWarn, logSuccess: exports.logSuccess };
|
package/dist/console/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/console/log.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAEnB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAQ,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/console/log.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAEnB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAQ,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAA,eAAK,GAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IAC9F,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,GAAG,OAGd;AAEK,MAA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QAAA,OAAO,WAGlB;AAEK,MAAM,UAAU,GAAG,CAAC,GAAG,GAAU,EAAE,EAAE;IAC3C,OAAO,CAAC,IAAI,CAAC,eAAK,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,IAAA,eAAK,GAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IAChG,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB;AAEF,MAAM,IAAI,GAAG,EAAE,GAAG,EAAH,WAAG,EAAE,OAAO,EAAP,eAAO,EAAE,MAAM,EAAN,cAAM,EAAE,QAAQ,EAAR,gBAAQ,EAAE,OAAO,EAAP,eAAO,EAAE,UAAU,EAAV,kBAAU,EAAE,CAAC;AAErE,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function getOS(): "android" | "win" | "aix" | "freebsd" | "haiku" | "linux" | "openbsd" | "sunos" | "cygwin" | "netbsd" | "mac";
|
|
2
|
+
export declare function isWin(): boolean;
|
|
3
|
+
export declare function isMac(): boolean;
|
|
4
|
+
export declare function isLinux(): boolean;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
getOS: typeof getOS;
|
|
7
|
+
isWin: typeof isWin;
|
|
8
|
+
isMac: typeof isMac;
|
|
9
|
+
isLinux: typeof isLinux;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isLinux = exports.isMac = exports.isWin = exports.getOS = void 0;
|
|
7
|
+
// var osvar = process.platform;
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
function getOS() {
|
|
10
|
+
const osvar = os_1.default.platform();
|
|
11
|
+
if (osvar == "darwin") {
|
|
12
|
+
return "mac";
|
|
13
|
+
}
|
|
14
|
+
else if (osvar == "win32") {
|
|
15
|
+
return "win";
|
|
16
|
+
}
|
|
17
|
+
else if (osvar == "linux") {
|
|
18
|
+
return "linux";
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return osvar;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.getOS = getOS;
|
|
25
|
+
function isWin() {
|
|
26
|
+
return os_1.default.platform() == "win32";
|
|
27
|
+
}
|
|
28
|
+
exports.isWin = isWin;
|
|
29
|
+
function isMac() {
|
|
30
|
+
return os_1.default.platform() == "darwin";
|
|
31
|
+
}
|
|
32
|
+
exports.isMac = isMac;
|
|
33
|
+
function isLinux() {
|
|
34
|
+
return os_1.default.platform() == "linux";
|
|
35
|
+
}
|
|
36
|
+
exports.isLinux = isLinux;
|
|
37
|
+
exports.default = { getOS, isWin, isMac, isLinux };
|
|
38
|
+
//# sourceMappingURL=os.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os.js","sourceRoot":"","sources":["../../src/device/os.ts"],"names":[],"mappings":";;;;;;AAAA,gCAAgC;AAChC,4CAAoB;AAEpB,SAAgB,KAAK;IACpB,MAAM,KAAK,GAAG,YAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,KAAK,IAAI,QAAQ,EAAE;QACtB,OAAO,KAAK,CAAC;KACb;SAAM,IAAI,KAAK,IAAI,OAAO,EAAE;QAC5B,OAAO,KAAK,CAAC;KACb;SAAM,IAAI,KAAK,IAAI,OAAO,EAAE;QAC5B,OAAO,OAAO,CAAC;KACf;SAAM;QACN,OAAO,KAAK,CAAC;KACb;AACF,CAAC;AAXD,sBAWC;AAED,SAAgB,KAAK;IACpB,OAAO,YAAE,CAAC,QAAQ,EAAE,IAAI,OAAO,CAAC;AACjC,CAAC;AAFD,sBAEC;AAED,SAAgB,KAAK;IACpB,OAAO,YAAE,CAAC,QAAQ,EAAE,IAAI,QAAQ,CAAC;AAClC,CAAC;AAFD,sBAEC;AAED,SAAgB,OAAO;IACtB,OAAO,YAAE,CAAC,QAAQ,EAAE,IAAI,OAAO,CAAC;AACjC,CAAC;AAFD,0BAEC;AAED,kBAAe,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
package/esm/console/log.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const log: (...msg: any) =>
|
|
2
|
-
export declare const logFull: (data?: {}) =>
|
|
3
|
-
export declare const logRes: (res: any, ...msg: any[]) =>
|
|
4
|
-
export declare const logError: (...msg: any[]) =>
|
|
5
|
-
export declare const logWarn: (...msg: any[]) =>
|
|
6
|
-
export declare const logSuccess: (...msg: any[]) =>
|
|
1
|
+
export declare const log: (...msg: any) => any;
|
|
2
|
+
export declare const logFull: (data?: {}) => {};
|
|
3
|
+
export declare const logRes: (res: any, ...msg: any[]) => any[];
|
|
4
|
+
export declare const logError: (...msg: any[]) => any[];
|
|
5
|
+
export declare const logWarn: (...msg: any[]) => any[];
|
|
6
|
+
export declare const logSuccess: (...msg: any[]) => any[];
|
|
7
7
|
declare const xlog: {
|
|
8
|
-
log: (...msg: any) =>
|
|
9
|
-
logFull: (data?: {}) =>
|
|
10
|
-
logRes: (res: any, ...msg: any[]) =>
|
|
11
|
-
logError: (...msg: any[]) =>
|
|
12
|
-
logWarn: (...msg: any[]) =>
|
|
13
|
-
logSuccess: (...msg: any[]) =>
|
|
8
|
+
log: (...msg: any) => any;
|
|
9
|
+
logFull: (data?: {}) => {};
|
|
10
|
+
logRes: (res: any, ...msg: any[]) => any[];
|
|
11
|
+
logError: (...msg: any[]) => any[];
|
|
12
|
+
logWarn: (...msg: any[]) => any[];
|
|
13
|
+
logSuccess: (...msg: any[]) => any[];
|
|
14
14
|
};
|
|
15
15
|
export default xlog;
|
package/esm/console/log.js
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
export const log = (...msg) => {
|
|
4
|
-
console.log(chalk.
|
|
4
|
+
console.log(chalk.bgBlue.white(`[LOGGING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
5
|
+
return msg;
|
|
5
6
|
};
|
|
6
7
|
export const logFull = (data = {}) => {
|
|
7
8
|
console.dir(data, { depth: null, colors: true, maxArrayLength: null });
|
|
9
|
+
return data;
|
|
8
10
|
};
|
|
9
11
|
export const logRes = (res, ...msg) => {
|
|
10
12
|
var _a, _b;
|
|
11
13
|
/**
|
|
12
14
|
* res.locals.req = Express Request
|
|
13
15
|
*/
|
|
14
|
-
// console.log(res.locals.req);
|
|
15
16
|
console.warn(chalk.blue(`[${res.statusCode}] ${((_a = res.locals.req) === null || _a === void 0 ? void 0 : _a.originalUrl) || "UNKNOWN_PATH"} >> ${(_b = res.locals.req) === null || _b === void 0 ? void 0 : _b.method} >>`), ...msg);
|
|
17
|
+
return msg;
|
|
16
18
|
};
|
|
17
19
|
export const logError = (...msg) => {
|
|
18
|
-
console.error(chalk.bgRed
|
|
20
|
+
console.error(chalk.bgRed.white(`[ERROR ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), chalk.red(...msg));
|
|
21
|
+
return msg;
|
|
19
22
|
};
|
|
20
23
|
export const logWarn = (...msg) => {
|
|
21
|
-
console.warn(chalk.
|
|
24
|
+
console.warn(chalk.bgYellow.black(`[WARNING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
25
|
+
return msg;
|
|
22
26
|
};
|
|
23
27
|
export const logSuccess = (...msg) => {
|
|
24
|
-
console.info(chalk.
|
|
28
|
+
console.info(chalk.bgGreen.black(`[SUCCESS ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
29
|
+
return msg;
|
|
25
30
|
};
|
|
26
31
|
const xlog = { log, logFull, logRes, logError, logWarn, logSuccess };
|
|
27
32
|
export default xlog;
|
package/esm/console/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/console/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,GAAQ,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/console/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,GAAQ,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IAC9F,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE;IACpC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAQ,EAAE,GAAG,GAAU,EAAE,EAAE;;IACjD;;OAEG;IACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,KAAK,CAAA,MAAA,GAAG,CAAC,MAAM,CAAC,GAAG,0CAAE,WAAW,KAA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bsd" | "mac";
|
|
2
|
+
export declare function isWin(): boolean;
|
|
3
|
+
export declare function isMac(): boolean;
|
|
4
|
+
export declare function isLinux(): boolean;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
getOS: typeof getOS;
|
|
7
|
+
isWin: typeof isWin;
|
|
8
|
+
isMac: typeof isMac;
|
|
9
|
+
isLinux: typeof isLinux;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
package/esm/device/os.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// var osvar = process.platform;
|
|
2
|
+
import os from "os";
|
|
3
|
+
export function getOS() {
|
|
4
|
+
const osvar = os.platform();
|
|
5
|
+
if (osvar == "darwin") {
|
|
6
|
+
return "mac";
|
|
7
|
+
}
|
|
8
|
+
else if (osvar == "win32") {
|
|
9
|
+
return "win";
|
|
10
|
+
}
|
|
11
|
+
else if (osvar == "linux") {
|
|
12
|
+
return "linux";
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return osvar;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function isWin() {
|
|
19
|
+
return os.platform() == "win32";
|
|
20
|
+
}
|
|
21
|
+
export function isMac() {
|
|
22
|
+
return os.platform() == "darwin";
|
|
23
|
+
}
|
|
24
|
+
export function isLinux() {
|
|
25
|
+
return os.platform() == "linux";
|
|
26
|
+
}
|
|
27
|
+
export default { getOS, isWin, isMac, isLinux };
|
|
28
|
+
//# sourceMappingURL=os.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os.js","sourceRoot":"","sources":["../../src/device/os.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,UAAU,KAAK;IACpB,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,KAAK,IAAI,QAAQ,EAAE;QACtB,OAAO,KAAK,CAAC;KACb;SAAM,IAAI,KAAK,IAAI,OAAO,EAAE;QAC5B,OAAO,KAAK,CAAC;KACb;SAAM,IAAI,KAAK,IAAI,OAAO,EAAE;QAC5B,OAAO,OAAO,CAAC;KACf;SAAM;QACN,OAAO,KAAK,CAAC;KACb;AACF,CAAC;AAED,MAAM,UAAU,KAAK;IACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,OAAO,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,KAAK;IACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,QAAQ,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,OAAO;IACtB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,OAAO,CAAC;AACjC,CAAC;AAED,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/console/log.ts
CHANGED
|
@@ -2,31 +2,36 @@ import chalk from "chalk";
|
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
|
|
4
4
|
export const log = (...msg: any) => {
|
|
5
|
-
console.log(chalk.
|
|
5
|
+
console.log(chalk.bgBlue.white(`[LOGGING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
6
|
+
return msg;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
export const logFull = (data = {}) => {
|
|
9
10
|
console.dir(data, { depth: null, colors: true, maxArrayLength: null });
|
|
11
|
+
return data;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export const logRes = (res: any, ...msg: any[]) => {
|
|
13
15
|
/**
|
|
14
16
|
* res.locals.req = Express Request
|
|
15
17
|
*/
|
|
16
|
-
// console.log(res.locals.req);
|
|
17
18
|
console.warn(chalk.blue(`[${res.statusCode}] ${res.locals.req?.originalUrl || "UNKNOWN_PATH"} >> ${res.locals.req?.method} >>`), ...msg);
|
|
19
|
+
return msg;
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
export const logError = (...msg: any[]) => {
|
|
21
|
-
console.error(chalk.bgRed
|
|
23
|
+
console.error(chalk.bgRed.white(`[ERROR ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), chalk.red(...msg));
|
|
24
|
+
return msg;
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export const logWarn = (...msg: any[]) => {
|
|
25
|
-
console.warn(chalk.
|
|
28
|
+
console.warn(chalk.bgYellow.black(`[WARNING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
29
|
+
return msg;
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
export const logSuccess = (...msg: any[]) => {
|
|
29
|
-
console.info(chalk.
|
|
33
|
+
console.info(chalk.bgGreen.black(`[SUCCESS ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
34
|
+
return msg;
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
const xlog = { log, logFull, logRes, logError, logWarn, logSuccess };
|
package/src/device/os.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// var osvar = process.platform;
|
|
2
|
+
import os from "os";
|
|
3
|
+
|
|
4
|
+
export function getOS() {
|
|
5
|
+
const osvar = os.platform();
|
|
6
|
+
if (osvar == "darwin") {
|
|
7
|
+
return "mac";
|
|
8
|
+
} else if (osvar == "win32") {
|
|
9
|
+
return "win";
|
|
10
|
+
} else if (osvar == "linux") {
|
|
11
|
+
return "linux";
|
|
12
|
+
} else {
|
|
13
|
+
return osvar;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isWin() {
|
|
18
|
+
return os.platform() == "win32";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isMac() {
|
|
22
|
+
return os.platform() == "darwin";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isLinux() {
|
|
26
|
+
return os.platform() == "linux";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default { getOS, isWin, isMac, isLinux };
|