@xube/kit-log 0.0.1
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/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/log-level.d.ts +11 -0
- package/dist/log-level.js +13 -0
- package/dist/xube-log.d.ts +13 -0
- package/dist/xube-log.js +43 -0
- package/package.json +22 -0
- package/src/index.ts +2 -0
- package/src/log-level.ts +13 -0
- package/src/xube-log.ts +45 -0
- package/tsconfig.json +8 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./log-level"), exports);
|
|
18
|
+
__exportStar(require("./xube-log"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const LOG_LEVEL_ERROR = 1;
|
|
2
|
+
export declare const LOG_LEVEL_WARN = 2;
|
|
3
|
+
export declare const LOG_LEVEL_INFO = 3;
|
|
4
|
+
export declare const LOG_LEVEL_DEBUG = 4;
|
|
5
|
+
export declare const LogLevel: {
|
|
6
|
+
readonly LOG_LEVEL_ERROR: 1;
|
|
7
|
+
readonly LOG_LEVEL_WARN: 2;
|
|
8
|
+
readonly LOG_LEVEL_INFO: 3;
|
|
9
|
+
readonly LOG_LEVEL_DEBUG: 4;
|
|
10
|
+
};
|
|
11
|
+
export type LogLevel = typeof LogLevel[keyof typeof LogLevel];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = exports.LOG_LEVEL_DEBUG = exports.LOG_LEVEL_INFO = exports.LOG_LEVEL_WARN = exports.LOG_LEVEL_ERROR = void 0;
|
|
4
|
+
exports.LOG_LEVEL_ERROR = 1;
|
|
5
|
+
exports.LOG_LEVEL_WARN = 2;
|
|
6
|
+
exports.LOG_LEVEL_INFO = 3;
|
|
7
|
+
exports.LOG_LEVEL_DEBUG = 4;
|
|
8
|
+
exports.LogLevel = {
|
|
9
|
+
LOG_LEVEL_ERROR: exports.LOG_LEVEL_ERROR,
|
|
10
|
+
LOG_LEVEL_WARN: exports.LOG_LEVEL_WARN,
|
|
11
|
+
LOG_LEVEL_INFO: exports.LOG_LEVEL_INFO,
|
|
12
|
+
LOG_LEVEL_DEBUG: exports.LOG_LEVEL_DEBUG,
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LogLevel } from "./log-level";
|
|
2
|
+
export declare class XubeLog {
|
|
3
|
+
level: LogLevel;
|
|
4
|
+
static instance: XubeLog;
|
|
5
|
+
private constructor();
|
|
6
|
+
static getInstance: (level?: LogLevel) => XubeLog;
|
|
7
|
+
error: (message: string, ...optionalParams: string[]) => void;
|
|
8
|
+
warn: (message: string, ...optionalParams: string[]) => void;
|
|
9
|
+
success: (message: string, ...optionalParams: string[]) => void;
|
|
10
|
+
log: (message: string, ...optionalParams: string[]) => void;
|
|
11
|
+
info: (message: string, ...optionalParams: string[]) => void;
|
|
12
|
+
debug: (message: string, ...optionalParams: string[]) => void;
|
|
13
|
+
}
|
package/dist/xube-log.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XubeLog = void 0;
|
|
4
|
+
const colors_1 = require("colors");
|
|
5
|
+
const log_level_1 = require("./log-level");
|
|
6
|
+
class XubeLog {
|
|
7
|
+
level;
|
|
8
|
+
static instance;
|
|
9
|
+
constructor(level) {
|
|
10
|
+
this.level = level;
|
|
11
|
+
}
|
|
12
|
+
static getInstance = (level = log_level_1.LogLevel.LOG_LEVEL_INFO) => {
|
|
13
|
+
if (!this.instance) {
|
|
14
|
+
this.instance = new XubeLog(level);
|
|
15
|
+
}
|
|
16
|
+
return this.instance;
|
|
17
|
+
};
|
|
18
|
+
error = (message, ...optionalParams) => {
|
|
19
|
+
console.error((0, colors_1.red)(message), optionalParams);
|
|
20
|
+
};
|
|
21
|
+
warn = (message, ...optionalParams) => {
|
|
22
|
+
if (this.level >= log_level_1.LogLevel.LOG_LEVEL_WARN) {
|
|
23
|
+
console.warn((0, colors_1.yellow)(message), optionalParams);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
success = (message, ...optionalParams) => {
|
|
27
|
+
if (this.level >= log_level_1.LogLevel.LOG_LEVEL_INFO) {
|
|
28
|
+
console.log((0, colors_1.green)(message), optionalParams);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
log = (message, ...optionalParams) => {
|
|
32
|
+
if (this.level >= log_level_1.LogLevel.LOG_LEVEL_INFO) {
|
|
33
|
+
console.log(message, optionalParams);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
info = this.log;
|
|
37
|
+
debug = (message, ...optionalParams) => {
|
|
38
|
+
if (this.level >= log_level_1.LogLevel.LOG_LEVEL_DEBUG) {
|
|
39
|
+
console.debug((0, colors_1.blue)(message), optionalParams);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.XubeLog = XubeLog;
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xube/kit-log",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+ssh://git@github.com/XubeLtd/dev-kit.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "Xube Pty Ltd",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/XubeLtd/dev-kit/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/XubeLtd/dev-kit#readme",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"colors": "^1.4.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
ADDED
package/src/log-level.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const LOG_LEVEL_ERROR = 1;
|
|
2
|
+
export const LOG_LEVEL_WARN = 2;
|
|
3
|
+
export const LOG_LEVEL_INFO = 3;
|
|
4
|
+
export const LOG_LEVEL_DEBUG = 4;
|
|
5
|
+
|
|
6
|
+
export const LogLevel = {
|
|
7
|
+
LOG_LEVEL_ERROR: LOG_LEVEL_ERROR,
|
|
8
|
+
LOG_LEVEL_WARN: LOG_LEVEL_WARN,
|
|
9
|
+
LOG_LEVEL_INFO: LOG_LEVEL_INFO,
|
|
10
|
+
LOG_LEVEL_DEBUG: LOG_LEVEL_DEBUG,
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export type LogLevel = typeof LogLevel[keyof typeof LogLevel];
|
package/src/xube-log.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { red, yellow, green, blue } from "colors";
|
|
2
|
+
import { LogLevel } from "./log-level";
|
|
3
|
+
|
|
4
|
+
export class XubeLog {
|
|
5
|
+
static instance: XubeLog;
|
|
6
|
+
|
|
7
|
+
private constructor(public level: LogLevel) {}
|
|
8
|
+
|
|
9
|
+
static getInstance = (level: LogLevel = LogLevel.LOG_LEVEL_INFO): XubeLog => {
|
|
10
|
+
if (!this.instance) {
|
|
11
|
+
this.instance = new XubeLog(level);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return this.instance;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
error = (message: string, ...optionalParams: string[]) => {
|
|
18
|
+
console.error(red(message), optionalParams);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
warn = (message: string, ...optionalParams: string[]) => {
|
|
22
|
+
if (this.level >= LogLevel.LOG_LEVEL_WARN) {
|
|
23
|
+
console.warn(yellow(message), optionalParams);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
success = (message: string, ...optionalParams: string[]) => {
|
|
28
|
+
if (this.level >= LogLevel.LOG_LEVEL_INFO) {
|
|
29
|
+
console.log(green(message), optionalParams);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
log = (message: string, ...optionalParams: string[]) => {
|
|
34
|
+
if (this.level >= LogLevel.LOG_LEVEL_INFO) {
|
|
35
|
+
console.log(message, optionalParams);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
info = this.log;
|
|
39
|
+
|
|
40
|
+
debug = (message: string, ...optionalParams: string[]) => {
|
|
41
|
+
if (this.level >= LogLevel.LOG_LEVEL_DEBUG) {
|
|
42
|
+
console.debug(blue(message), optionalParams);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|