@ribbon-studios/logger 3.0.1 → 3.1.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/README.md +2 -5
- package/dist/index.cjs +1 -1
- package/dist/index.js +27 -16
- package/dist/utils/__tests__/random.spec.d.ts +1 -0
- package/dist/utils/random.d.ts +1 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
[![Coveralls][coveralls-image]][coveralls-url]
|
|
6
6
|
|
|
7
7
|
[![CI Build][github-actions-image]][github-actions-url]
|
|
8
|
-
[![Maintainability][maintainability-image]][maintainability-url]
|
|
9
8
|
[![Semantic Release][semantic-release-image]][semantic-release-url]
|
|
10
9
|
[![Code Style: Prettier][code-style-image]][code-style-url]
|
|
11
10
|
|
|
@@ -27,13 +26,11 @@ logger.error('hello', 'world!'); // '[error]: hello world!'
|
|
|
27
26
|
[npm-version-image]: https://img.shields.io/npm/v/@ribbon-studios/logger.svg
|
|
28
27
|
[npm-downloads-image]: https://img.shields.io/npm/dm/@ribbon-studios/logger.svg
|
|
29
28
|
[npm-url]: https://npmjs.org/package/@ribbon-studios/logger
|
|
30
|
-
[github-actions-image]: https://
|
|
31
|
-
[github-actions-url]: https://
|
|
29
|
+
[github-actions-image]: https://codeberg.org/ribbon-studios/logger/badges/workflows/ci.yml/badge.svg?branch=main
|
|
30
|
+
[github-actions-url]: https://codeberg.org/ribbon-studios/logger/actions?workflow=ci.yml&branch=main
|
|
32
31
|
[coveralls-image]: https://img.shields.io/coveralls/ribbon-studios/logger.svg
|
|
33
32
|
[coveralls-url]: https://coveralls.io/github/ribbon-studios/logger?branch=main
|
|
34
33
|
[code-style-image]: https://img.shields.io/badge/code%20style-prettier-ff69b4.svg
|
|
35
34
|
[code-style-url]: https://prettier.io
|
|
36
|
-
[maintainability-image]: https://img.shields.io/codeclimate/maintainability/ribbon-studios/refreshly
|
|
37
|
-
[maintainability-url]: https://codeclimate.com/github/ribbon-studios/refreshly/maintainability
|
|
38
35
|
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
39
36
|
[semantic-release-image]: https://img.shields.io/badge/%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`chalk`);c=s(c);function l(e){let t=new Set;return JSON.stringify(e,(e,n)=>{if(typeof n==`object`&&n){if(t.has(n))return;t.add(n)}return n},4)}function u(e){return e.map(e=>e instanceof Error||typeof e!=`object`?e:l(e))}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`chalk`);c=s(c);function l(e){let t=new Set;return JSON.stringify(e,(e,n)=>{if(typeof n==`object`&&n){if(t.has(n))return;t.add(n)}return n},4)}function u(e){return e.map(e=>e instanceof Error||typeof e!=`object`?e:l(e))}function d(e,t,n){let r=2166136261;for(let t=0;t<e.length;t++)r^=e.charCodeAt(t),r=r*16777619>>>0;return t+r%(n-t+1)}var f=function(e){return e[e.ERROR=0]=`ERROR`,e[e.WARN=1]=`WARN`,e[e.INFO=2]=`INFO`,e[e.SILLY=3]=`SILLY`,e}({}),p=Object.keys(f).reduce((e,t)=>Math.max(e,t.length),0)+2,m={[f.ERROR]:c.default.red,[f.WARN]:c.default.yellow,[f.INFO]:c.default.cyan,[f.SILLY]:c.default.magenta},h=class{#e;constructor(e){this.#e={level:f.INFO,...typeof e==`string`?{scope:e}:e},this.#e.scope&&(this.prefix=c.default.rgb(d(`${this.#e.scope}:r`,0,255),d(`${this.#e.scope}:g`,0,255),d(`${this.#e.scope}:b`,0,255))(`[${this.#e.scope}]`))}isLevel(e){return e!=null&&this.#e.level>=e}isNotLevel(e){return!this.isLevel(e)}setLevel(e){this.#e.level=e}log(e,...t){if(this.isNotLevel(e))return;let n=m[e],r=u(t).map(e=>e instanceof Error?e:n(e)),i=[n(`[${f[e].toLowerCase()}]`.padStart(p,` `)),this.prefix,`:`].filter(Boolean).join(``);console.log(i,...r)}error(...e){this.log(f.ERROR,...e)}warn(...e){this.log(f.WARN,...e)}info(...e){this.log(f.INFO,...e)}silly(...e){this.log(f.SILLY,...e)}},g=new h;exports.LEVEL_CHALK=m,exports.LogLevel=f,exports.MAX_LENGTH=p,exports.RibbonLogger=h,exports.logger=g;
|
package/dist/index.js
CHANGED
|
@@ -16,21 +16,28 @@ function n(e) {
|
|
|
16
16
|
return e.map((e) => e instanceof Error || typeof e != "object" ? e : t(e));
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
|
+
//#region src/utils/random.ts
|
|
20
|
+
function r(e, t, n) {
|
|
21
|
+
let r = 2166136261;
|
|
22
|
+
for (let t = 0; t < e.length; t++) r ^= e.charCodeAt(t), r = r * 16777619 >>> 0;
|
|
23
|
+
return t + r % (n - t + 1);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
19
26
|
//#region src/logger.ts
|
|
20
|
-
var
|
|
27
|
+
var i = /* @__PURE__ */ function(e) {
|
|
21
28
|
return e[e.ERROR = 0] = "ERROR", e[e.WARN = 1] = "WARN", e[e.INFO = 2] = "INFO", e[e.SILLY = 3] = "SILLY", e;
|
|
22
|
-
}({}),
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
},
|
|
29
|
+
}({}), a = Object.keys(i).reduce((e, t) => Math.max(e, t.length), 0) + 2, o = {
|
|
30
|
+
[i.ERROR]: e.red,
|
|
31
|
+
[i.WARN]: e.yellow,
|
|
32
|
+
[i.INFO]: e.cyan,
|
|
33
|
+
[i.SILLY]: e.magenta
|
|
34
|
+
}, s = class {
|
|
28
35
|
#e;
|
|
29
36
|
constructor(t) {
|
|
30
37
|
this.#e = {
|
|
31
|
-
level:
|
|
38
|
+
level: i.INFO,
|
|
32
39
|
...typeof t == "string" ? { scope: t } : t
|
|
33
|
-
}, this.#e.scope && (this.prefix = e.rgb(
|
|
40
|
+
}, this.#e.scope && (this.prefix = e.rgb(r(`${this.#e.scope}:r`, 0, 255), r(`${this.#e.scope}:g`, 0, 255), r(`${this.#e.scope}:b`, 0, 255))(`[${this.#e.scope}]`));
|
|
34
41
|
}
|
|
35
42
|
isLevel(e) {
|
|
36
43
|
return e != null && this.#e.level >= e;
|
|
@@ -43,21 +50,25 @@ var r = /* @__PURE__ */ function(e) {
|
|
|
43
50
|
}
|
|
44
51
|
log(e, ...t) {
|
|
45
52
|
if (this.isNotLevel(e)) return;
|
|
46
|
-
let
|
|
53
|
+
let r = o[e], s = n(t).map((e) => e instanceof Error ? e : r(e)), c = [
|
|
54
|
+
r(`[${i[e].toLowerCase()}]`.padStart(a, " ")),
|
|
55
|
+
this.prefix,
|
|
56
|
+
":"
|
|
57
|
+
].filter(Boolean).join("");
|
|
47
58
|
console.log(c, ...s);
|
|
48
59
|
}
|
|
49
60
|
error(...e) {
|
|
50
|
-
this.log(
|
|
61
|
+
this.log(i.ERROR, ...e);
|
|
51
62
|
}
|
|
52
63
|
warn(...e) {
|
|
53
|
-
this.log(
|
|
64
|
+
this.log(i.WARN, ...e);
|
|
54
65
|
}
|
|
55
66
|
info(...e) {
|
|
56
|
-
this.log(
|
|
67
|
+
this.log(i.INFO, ...e);
|
|
57
68
|
}
|
|
58
69
|
silly(...e) {
|
|
59
|
-
this.log(
|
|
70
|
+
this.log(i.SILLY, ...e);
|
|
60
71
|
}
|
|
61
|
-
},
|
|
72
|
+
}, c = new s();
|
|
62
73
|
//#endregion
|
|
63
|
-
export {
|
|
74
|
+
export { o as LEVEL_CHALK, i as LogLevel, a as MAX_LENGTH, s as RibbonLogger, c as logger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function random(seed: string, min: number, max: number): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ribbon-studios/logger",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A simple logger for all Ribbon Studios Apps & Libraries",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"test:coverage": "vitest --coverage"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"chalk": "^5.
|
|
17
|
+
"chalk": "^5.6.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
+
"@fsl-s/semantic-release-forgejo": "^1.0.0",
|
|
20
21
|
"@types/chance": "^1.1.7",
|
|
21
22
|
"@types/node": "^22.19.15",
|
|
22
23
|
"@vitest/coverage-v8": "4.1.0",
|
|
@@ -25,10 +26,11 @@
|
|
|
25
26
|
"dedent": "^1.7.2",
|
|
26
27
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
27
28
|
"jiti": "^2.6.1",
|
|
29
|
+
"semantic-release": "^22",
|
|
28
30
|
"string-dedent": "^3.0.2",
|
|
29
31
|
"typescript": "^5.9.3",
|
|
30
|
-
"typescript-eslint": "^8.57.
|
|
31
|
-
"vite": "^8.0.
|
|
32
|
+
"typescript-eslint": "^8.57.1",
|
|
33
|
+
"vite": "^8.0.1",
|
|
32
34
|
"vite-plugin-dts": "^4.5.4",
|
|
33
35
|
"vitest": "^4.1.0"
|
|
34
36
|
},
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
},
|
|
38
40
|
"repository": {
|
|
39
41
|
"type": "git",
|
|
40
|
-
"url": "git+https://
|
|
42
|
+
"url": "git+https://codeberg.org/ribbon-studios/logger.git"
|
|
41
43
|
},
|
|
42
44
|
"license": "MIT"
|
|
43
45
|
}
|