@wsurface/debug 2.0.3 → 2.0.4

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 CHANGED
@@ -8,7 +8,7 @@
8
8
  </p>
9
9
 
10
10
  <p align="center">
11
- <a href="https://github.com/nuneswip/wsurface-debug">
11
+ <a href="https://github.com/nuneswip/surface-debug">
12
12
  <img src="https://img.shields.io/badge/GitHub-Repository-181717?style=for-the-badge&logo=github&logoColor=white" />
13
13
  </a>
14
14
  <a href="https://www.npmjs.com/package/@wsurface/debug">
@@ -64,7 +64,7 @@ pnpm add @wsurface/debug
64
64
  </p>
65
65
 
66
66
  <p align="center">
67
- <a href="https://surfacedocs.onrender.com/debug">
67
+ <a href="https://github.com/nuneswip/wsurface-debug/tree/main/docs">
68
68
  View Documentation
69
69
  </a>
70
70
  </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wsurface/debug",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "A simple and powerful logger for your project.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,17 +14,19 @@
14
14
  "logger",
15
15
  "nodejs",
16
16
  "shell",
17
+ "console",
17
18
  "terminal",
18
19
  "cli",
19
20
  "string",
20
21
  "text"
21
22
  ],
22
23
  "type": "module",
23
- "main": "./src/cjs/index.cjs",
24
+ "main": "./src/esm/index.mjs",
24
25
  "exports": {
25
26
  "import": "./src/esm/index.mjs",
26
27
  "require": "./src/cjs/index.cjs"
27
28
  },
29
+ "scripts": {},
28
30
  "files": ["src", "package.json", "README.md", "LICENSE.txt"],
29
31
  "author": "nuneswip",
30
32
  "license": "CC-BY-ND-4.0",
package/src/cjs/index.cjs CHANGED
@@ -1,4 +1,3 @@
1
1
  const { logger } = require("./modules/logger.cjs");
2
2
 
3
3
  module.exports = logger;
4
- module.exports.logger = logger;
@@ -16,7 +16,7 @@ const DEFAULT_THEME = {
16
16
  conn: "blue"
17
17
  };
18
18
 
19
- const DEFAULT_ICONS = {
19
+ const ICONS = {
20
20
  info: "ℹ",
21
21
  warn: "⚠",
22
22
  error: "✖",
@@ -32,7 +32,6 @@ class Logger {
32
32
  icons: true,
33
33
  tag: true,
34
34
  theme: DEFAULT_THEME,
35
- iconSet: DEFAULT_ICONS,
36
35
  ...options
37
36
  };
38
37
 
@@ -68,25 +67,13 @@ class Logger {
68
67
  if (!start) return;
69
68
 
70
69
  const duration = Date.now() - start;
70
+
71
71
  this.info(`⏱ ${label}: ${duration}ms`);
72
72
  this.timers.delete(label);
73
73
  }
74
74
  };
75
75
  }
76
76
 
77
- getIcon(level, options) {
78
- if (!options.icons) return "";
79
-
80
- const iconSet = {
81
- ...DEFAULT_ICONS,
82
- ...options.iconSet
83
- };
84
-
85
- const icon = iconSet[level];
86
-
87
- return icon ? icon + " " : "";
88
- }
89
-
90
77
  createMode(options) {
91
78
  const mode = {};
92
79
 
@@ -103,8 +90,7 @@ class Logger {
103
90
 
104
91
  this.levels.forEach(level => {
105
92
  box[level] = msg => {
106
- const icon = this.getIcon(level, this.options);
107
- const text = ` ${icon}${msg} `;
93
+ const text = ` ${ICONS[level]} ${msg} `;
108
94
  const line = "─".repeat(text.length);
109
95
 
110
96
  console.log(`┌${line}┐`);
@@ -140,16 +126,7 @@ class Logger {
140
126
  }
141
127
 
142
128
  setOptions(options) {
143
- this.options = {
144
- ...this.options,
145
- ...options,
146
- iconSet: options.iconSet
147
- ? {
148
- ...this.options.iconSet,
149
- ...options.iconSet
150
- }
151
- : this.options.iconSet
152
- };
129
+ this.options = { ...this.options, ...options };
153
130
  }
154
131
 
155
132
  formatTimestamp(enabled) {
@@ -174,7 +151,7 @@ class Logger {
174
151
 
175
152
  const color = c[theme[level]] || c.white;
176
153
 
177
- const icon = this.getIcon(level, merged);
154
+ const icon = merged.icons ? `${ICONS[level]} ` : "";
178
155
 
179
156
  const timestamp = this.formatTimestamp(merged.timestamp);
180
157
 
package/src/esm/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
1
  import { logger } from "./modules/logger.mjs";
2
2
 
3
- export { logger };
4
3
  export default logger;
@@ -11,7 +11,7 @@ const DEFAULT_THEME = {
11
11
  conn: "blue"
12
12
  };
13
13
 
14
- const DEFAULT_ICONS = {
14
+ const ICONS = {
15
15
  info: "ℹ",
16
16
  warn: "⚠",
17
17
  error: "✖",
@@ -27,7 +27,6 @@ class Logger {
27
27
  icons: true,
28
28
  tag: true,
29
29
  theme: DEFAULT_THEME,
30
- iconSet: DEFAULT_ICONS,
31
30
  ...options
32
31
  };
33
32
 
@@ -42,6 +41,7 @@ class Logger {
42
41
  });
43
42
 
44
43
  this.box = this.createBox();
44
+
45
45
  this.json = this.createJSON();
46
46
 
47
47
  this.group = {
@@ -70,19 +70,6 @@ class Logger {
70
70
  };
71
71
  }
72
72
 
73
- getIcon(level, options) {
74
- if (!options.icons) return "";
75
-
76
- const iconSet = {
77
- ...DEFAULT_ICONS,
78
- ...options.iconSet
79
- };
80
-
81
- const icon = iconSet[level];
82
-
83
- return icon ? icon + " " : "";
84
- }
85
-
86
73
  createMode(options) {
87
74
  const mode = {};
88
75
  this.levels.forEach(level => {
@@ -97,8 +84,7 @@ class Logger {
97
84
 
98
85
  this.levels.forEach(level => {
99
86
  box[level] = msg => {
100
- const icon = this.getIcon(level, this.options);
101
- const text = ` ${icon}${msg} `;
87
+ const text = ` ${ICONS[level]} ${msg} `;
102
88
  const line = "─".repeat(text.length);
103
89
 
104
90
  console.log(`┌${line}┐`);
@@ -134,16 +120,7 @@ class Logger {
134
120
  }
135
121
 
136
122
  setOptions(options) {
137
- this.options = {
138
- ...this.options,
139
- ...options,
140
- iconSet: options.iconSet
141
- ? {
142
- ...this.options.iconSet,
143
- ...options.iconSet
144
- }
145
- : this.options.iconSet
146
- };
123
+ this.options = { ...this.options, ...options };
147
124
  }
148
125
 
149
126
  formatTimestamp(enabled) {
@@ -166,7 +143,7 @@ class Logger {
166
143
 
167
144
  const color = chalk[theme[level]] || chalk.white;
168
145
 
169
- const icon = this.getIcon(level, merged);
146
+ const icon = merged.icons ? `${ICONS[level]} ` : "";
170
147
 
171
148
  const timestamp = this.formatTimestamp(merged.timestamp);
172
149