@pandacss/logger 0.0.0-dev-20230411123239 → 0.0.0-dev-20230411200729
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 +5 -40
- package/dist/index.js +44 -23
- package/dist/index.mjs +43 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
import colors from 'kleur';
|
|
2
1
|
export { default as colors } from 'kleur';
|
|
3
2
|
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
color: colors.Color;
|
|
8
|
-
};
|
|
9
|
-
info: {
|
|
10
|
-
weight: number;
|
|
11
|
-
color: colors.Color;
|
|
12
|
-
};
|
|
13
|
-
warn: {
|
|
14
|
-
weight: number;
|
|
15
|
-
color: colors.Color;
|
|
16
|
-
};
|
|
17
|
-
error: {
|
|
18
|
-
weight: number;
|
|
19
|
-
color: colors.Color;
|
|
20
|
-
};
|
|
21
|
-
silent: {
|
|
22
|
-
weight: number;
|
|
23
|
-
color: colors.Color;
|
|
24
|
-
};
|
|
3
|
+
declare const createLogScope: (scope: string) => {
|
|
4
|
+
(subScope: string): string;
|
|
5
|
+
toString(): string;
|
|
25
6
|
};
|
|
26
|
-
|
|
7
|
+
|
|
27
8
|
declare const quote: (...str: string[]) => string;
|
|
28
|
-
type Config = {
|
|
29
|
-
level?: LogLevel;
|
|
30
|
-
filter?: string;
|
|
31
|
-
};
|
|
32
|
-
declare const createLogger: (conf?: Config) => {
|
|
33
|
-
level: "debug" | "info" | "warn" | "error" | "silent";
|
|
34
|
-
warn: (type: string, data: any) => void;
|
|
35
|
-
info: (type: string, data: any) => void;
|
|
36
|
-
debug: (type: string, data: any) => void;
|
|
37
|
-
error: (type: string, data: any) => void;
|
|
38
|
-
log: (data: string) => void;
|
|
39
|
-
time: {
|
|
40
|
-
info: (msg: string) => () => void;
|
|
41
|
-
debug: (msg: string) => () => void;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
9
|
declare const logger: {
|
|
45
10
|
level: "debug" | "info" | "warn" | "error" | "silent";
|
|
46
11
|
warn: (type: string, data: any) => void;
|
|
@@ -54,4 +19,4 @@ declare const logger: {
|
|
|
54
19
|
};
|
|
55
20
|
};
|
|
56
21
|
|
|
57
|
-
export {
|
|
22
|
+
export { createLogScope, logger, quote };
|
package/dist/index.js
CHANGED
|
@@ -30,14 +30,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
colors: () =>
|
|
34
|
-
|
|
33
|
+
colors: () => import_kleur4.default,
|
|
34
|
+
createLogScope: () => createLogScope,
|
|
35
35
|
logger: () => logger,
|
|
36
36
|
quote: () => quote
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
|
39
|
-
var
|
|
40
|
-
|
|
39
|
+
var import_kleur4 = __toESM(require("kleur"));
|
|
40
|
+
|
|
41
|
+
// src/create-logger.ts
|
|
42
|
+
var import_kleur3 = __toESM(require("kleur"));
|
|
43
|
+
var import_lil_fp2 = require("lil-fp");
|
|
41
44
|
|
|
42
45
|
// ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
|
|
43
46
|
function escapeStringRegexp(string) {
|
|
@@ -125,7 +128,12 @@ function isMatch(inputs, patterns, options) {
|
|
|
125
128
|
return baseMatcher(inputs, patterns, options, true).length > 0;
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
// src/
|
|
131
|
+
// src/format-entry.ts
|
|
132
|
+
var import_kleur2 = __toESM(require("kleur"));
|
|
133
|
+
var import_lil_fp = require("lil-fp");
|
|
134
|
+
|
|
135
|
+
// src/levels.ts
|
|
136
|
+
var import_kleur = __toESM(require("kleur"));
|
|
129
137
|
var logLevels = {
|
|
130
138
|
debug: { weight: 0, color: import_kleur.default.magenta },
|
|
131
139
|
info: { weight: 1, color: import_kleur.default.blue },
|
|
@@ -133,14 +141,12 @@ var logLevels = {
|
|
|
133
141
|
error: { weight: 3, color: import_kleur.default.red },
|
|
134
142
|
silent: { weight: 4, color: import_kleur.default.white }
|
|
135
143
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return { type, level, msg };
|
|
139
|
-
};
|
|
144
|
+
|
|
145
|
+
// src/format-entry.ts
|
|
140
146
|
var formatEntry = (entry) => (0, import_lil_fp.pipe)(
|
|
141
147
|
{ entry },
|
|
142
148
|
import_lil_fp.Obj.assign(({ entry: entry2 }) => ({
|
|
143
|
-
uword: entry2.type ?
|
|
149
|
+
uword: entry2.type ? import_kleur2.default.gray(`[${entry2.type}]`) : ""
|
|
144
150
|
})),
|
|
145
151
|
(0, import_lil_fp.match)(
|
|
146
152
|
(0, import_lil_fp.when)(
|
|
@@ -148,7 +154,7 @@ var formatEntry = (entry) => (0, import_lil_fp.pipe)(
|
|
|
148
154
|
({ entry: entry2, uword }) => {
|
|
149
155
|
const { msg, level } = entry2;
|
|
150
156
|
const color = logLevels[level].color;
|
|
151
|
-
const label =
|
|
157
|
+
const label = import_kleur2.default.bold(color(`${level}`));
|
|
152
158
|
return { label: [`\u{1F43C}`, label, uword].filter(Boolean).join(" "), msg };
|
|
153
159
|
}
|
|
154
160
|
),
|
|
@@ -158,38 +164,43 @@ var formatEntry = (entry) => (0, import_lil_fp.pipe)(
|
|
|
158
164
|
})
|
|
159
165
|
)
|
|
160
166
|
);
|
|
161
|
-
var
|
|
167
|
+
var createEntry = (level, type, data) => {
|
|
168
|
+
const msg = data instanceof Error ? import_kleur2.default.red(data.message) : data;
|
|
169
|
+
return { type, level, msg };
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/create-logger.ts
|
|
162
173
|
var matches = (filters, value) => filters.some((search) => isMatch(value, search));
|
|
163
174
|
var createLogger = (conf = {}) => {
|
|
164
175
|
let level = conf.level ?? "info";
|
|
165
|
-
const { stdout, timing } = (0,
|
|
176
|
+
const { stdout, timing } = (0, import_lil_fp2.pipe)(
|
|
166
177
|
conf,
|
|
167
178
|
({ filter }) => ({
|
|
168
179
|
getLevel: () => filter ? "debug" : level,
|
|
169
180
|
filter: filter !== "*" ? filter?.split(/[\s,]+/) ?? [] : []
|
|
170
181
|
}),
|
|
171
|
-
|
|
172
|
-
|
|
182
|
+
import_lil_fp2.Obj.assignTo("config"),
|
|
183
|
+
import_lil_fp2.Obj.assign(({ config }) => ({
|
|
173
184
|
isValid(level2, type) {
|
|
174
185
|
const badLevel = logLevels[config.getLevel()].weight > logLevels[level2].weight;
|
|
175
186
|
const badType = config.filter.length > 0 && !matches(config.filter, type);
|
|
176
187
|
return !(badType || badLevel);
|
|
177
188
|
}
|
|
178
189
|
})),
|
|
179
|
-
|
|
190
|
+
import_lil_fp2.Obj.assign(({ isValid, config }) => ({
|
|
180
191
|
stdout(level2) {
|
|
181
192
|
return (type, data) => {
|
|
182
|
-
(0,
|
|
193
|
+
(0, import_lil_fp2.pipe)(
|
|
183
194
|
createEntry(level2, type, data),
|
|
184
|
-
(0,
|
|
185
|
-
(0,
|
|
195
|
+
(0, import_lil_fp2.match)(
|
|
196
|
+
(0, import_lil_fp2.when)(
|
|
186
197
|
({ level: level3, type: type2 }) => level3 != null && isValid(level3, type2),
|
|
187
198
|
(entry) => {
|
|
188
199
|
const { msg, label } = formatEntry(entry) ?? {};
|
|
189
200
|
console.log(label, msg);
|
|
190
201
|
}
|
|
191
202
|
),
|
|
192
|
-
(0,
|
|
203
|
+
(0, import_lil_fp2.when)(
|
|
193
204
|
({ level: level3 }) => config.getLevel() !== "silent" && level3 == null,
|
|
194
205
|
() => {
|
|
195
206
|
console.log(...[type, data].filter(Boolean));
|
|
@@ -200,13 +211,13 @@ var createLogger = (conf = {}) => {
|
|
|
200
211
|
};
|
|
201
212
|
}
|
|
202
213
|
})),
|
|
203
|
-
|
|
214
|
+
import_lil_fp2.Obj.assign(({ stdout: stdout2 }) => ({
|
|
204
215
|
timing: (level2) => (msg) => {
|
|
205
216
|
const start = performance.now();
|
|
206
217
|
return () => {
|
|
207
218
|
const end = performance.now();
|
|
208
219
|
const ms = end - start;
|
|
209
|
-
stdout2(level2)("hrtime", `${msg} ${
|
|
220
|
+
stdout2(level2)("hrtime", `${msg} ${import_kleur3.default.gray(`(${ms.toFixed(2)}ms)`)}`);
|
|
210
221
|
};
|
|
211
222
|
}
|
|
212
223
|
}))
|
|
@@ -229,13 +240,23 @@ var createLogger = (conf = {}) => {
|
|
|
229
240
|
}
|
|
230
241
|
};
|
|
231
242
|
};
|
|
243
|
+
|
|
244
|
+
// src/scope.ts
|
|
245
|
+
var createLogScope = (scope) => {
|
|
246
|
+
const fn = (subScope) => `${scope}/${subScope}`;
|
|
247
|
+
fn.toString = () => scope;
|
|
248
|
+
return fn;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// src/index.ts
|
|
252
|
+
var quote = (...str) => import_kleur4.default.cyan(`\`${str.join("")}\``);
|
|
232
253
|
var logger = createLogger({
|
|
233
254
|
filter: typeof process !== "undefined" ? process.env.PANDA_DEBUG : void 0
|
|
234
255
|
});
|
|
235
256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
236
257
|
0 && (module.exports = {
|
|
237
258
|
colors,
|
|
238
|
-
|
|
259
|
+
createLogScope,
|
|
239
260
|
logger,
|
|
240
261
|
quote
|
|
241
262
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import colors4 from "kleur";
|
|
3
|
+
|
|
4
|
+
// src/create-logger.ts
|
|
5
|
+
import colors3 from "kleur";
|
|
6
|
+
import { match as match2, Obj as Obj2, pipe as pipe2, when as when2 } from "lil-fp";
|
|
4
7
|
|
|
5
8
|
// ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
|
|
6
9
|
function escapeStringRegexp(string) {
|
|
@@ -88,7 +91,12 @@ function isMatch(inputs, patterns, options) {
|
|
|
88
91
|
return baseMatcher(inputs, patterns, options, true).length > 0;
|
|
89
92
|
}
|
|
90
93
|
|
|
91
|
-
// src/
|
|
94
|
+
// src/format-entry.ts
|
|
95
|
+
import colors2 from "kleur";
|
|
96
|
+
import { match, Obj, otherwise, pipe, when } from "lil-fp";
|
|
97
|
+
|
|
98
|
+
// src/levels.ts
|
|
99
|
+
import colors from "kleur";
|
|
92
100
|
var logLevels = {
|
|
93
101
|
debug: { weight: 0, color: colors.magenta },
|
|
94
102
|
info: { weight: 1, color: colors.blue },
|
|
@@ -96,14 +104,12 @@ var logLevels = {
|
|
|
96
104
|
error: { weight: 3, color: colors.red },
|
|
97
105
|
silent: { weight: 4, color: colors.white }
|
|
98
106
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return { type, level, msg };
|
|
102
|
-
};
|
|
107
|
+
|
|
108
|
+
// src/format-entry.ts
|
|
103
109
|
var formatEntry = (entry) => pipe(
|
|
104
110
|
{ entry },
|
|
105
111
|
Obj.assign(({ entry: entry2 }) => ({
|
|
106
|
-
uword: entry2.type ?
|
|
112
|
+
uword: entry2.type ? colors2.gray(`[${entry2.type}]`) : ""
|
|
107
113
|
})),
|
|
108
114
|
match(
|
|
109
115
|
when(
|
|
@@ -111,7 +117,7 @@ var formatEntry = (entry) => pipe(
|
|
|
111
117
|
({ entry: entry2, uword }) => {
|
|
112
118
|
const { msg, level } = entry2;
|
|
113
119
|
const color = logLevels[level].color;
|
|
114
|
-
const label =
|
|
120
|
+
const label = colors2.bold(color(`${level}`));
|
|
115
121
|
return { label: [`\u{1F43C}`, label, uword].filter(Boolean).join(" "), msg };
|
|
116
122
|
}
|
|
117
123
|
),
|
|
@@ -121,38 +127,43 @@ var formatEntry = (entry) => pipe(
|
|
|
121
127
|
})
|
|
122
128
|
)
|
|
123
129
|
);
|
|
124
|
-
var
|
|
130
|
+
var createEntry = (level, type, data) => {
|
|
131
|
+
const msg = data instanceof Error ? colors2.red(data.message) : data;
|
|
132
|
+
return { type, level, msg };
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/create-logger.ts
|
|
125
136
|
var matches = (filters, value) => filters.some((search) => isMatch(value, search));
|
|
126
137
|
var createLogger = (conf = {}) => {
|
|
127
138
|
let level = conf.level ?? "info";
|
|
128
|
-
const { stdout, timing } =
|
|
139
|
+
const { stdout, timing } = pipe2(
|
|
129
140
|
conf,
|
|
130
141
|
({ filter }) => ({
|
|
131
142
|
getLevel: () => filter ? "debug" : level,
|
|
132
143
|
filter: filter !== "*" ? filter?.split(/[\s,]+/) ?? [] : []
|
|
133
144
|
}),
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
Obj2.assignTo("config"),
|
|
146
|
+
Obj2.assign(({ config }) => ({
|
|
136
147
|
isValid(level2, type) {
|
|
137
148
|
const badLevel = logLevels[config.getLevel()].weight > logLevels[level2].weight;
|
|
138
149
|
const badType = config.filter.length > 0 && !matches(config.filter, type);
|
|
139
150
|
return !(badType || badLevel);
|
|
140
151
|
}
|
|
141
152
|
})),
|
|
142
|
-
|
|
153
|
+
Obj2.assign(({ isValid, config }) => ({
|
|
143
154
|
stdout(level2) {
|
|
144
155
|
return (type, data) => {
|
|
145
|
-
|
|
156
|
+
pipe2(
|
|
146
157
|
createEntry(level2, type, data),
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
match2(
|
|
159
|
+
when2(
|
|
149
160
|
({ level: level3, type: type2 }) => level3 != null && isValid(level3, type2),
|
|
150
161
|
(entry) => {
|
|
151
162
|
const { msg, label } = formatEntry(entry) ?? {};
|
|
152
163
|
console.log(label, msg);
|
|
153
164
|
}
|
|
154
165
|
),
|
|
155
|
-
|
|
166
|
+
when2(
|
|
156
167
|
({ level: level3 }) => config.getLevel() !== "silent" && level3 == null,
|
|
157
168
|
() => {
|
|
158
169
|
console.log(...[type, data].filter(Boolean));
|
|
@@ -163,13 +174,13 @@ var createLogger = (conf = {}) => {
|
|
|
163
174
|
};
|
|
164
175
|
}
|
|
165
176
|
})),
|
|
166
|
-
|
|
177
|
+
Obj2.assign(({ stdout: stdout2 }) => ({
|
|
167
178
|
timing: (level2) => (msg) => {
|
|
168
179
|
const start = performance.now();
|
|
169
180
|
return () => {
|
|
170
181
|
const end = performance.now();
|
|
171
182
|
const ms = end - start;
|
|
172
|
-
stdout2(level2)("hrtime", `${msg} ${
|
|
183
|
+
stdout2(level2)("hrtime", `${msg} ${colors3.gray(`(${ms.toFixed(2)}ms)`)}`);
|
|
173
184
|
};
|
|
174
185
|
}
|
|
175
186
|
}))
|
|
@@ -192,12 +203,22 @@ var createLogger = (conf = {}) => {
|
|
|
192
203
|
}
|
|
193
204
|
};
|
|
194
205
|
};
|
|
206
|
+
|
|
207
|
+
// src/scope.ts
|
|
208
|
+
var createLogScope = (scope) => {
|
|
209
|
+
const fn = (subScope) => `${scope}/${subScope}`;
|
|
210
|
+
fn.toString = () => scope;
|
|
211
|
+
return fn;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// src/index.ts
|
|
215
|
+
var quote = (...str) => colors4.cyan(`\`${str.join("")}\``);
|
|
195
216
|
var logger = createLogger({
|
|
196
217
|
filter: typeof process !== "undefined" ? process.env.PANDA_DEBUG : void 0
|
|
197
218
|
});
|
|
198
219
|
export {
|
|
199
|
-
colors,
|
|
200
|
-
|
|
220
|
+
colors4 as colors,
|
|
221
|
+
createLogScope,
|
|
201
222
|
logger,
|
|
202
223
|
quote
|
|
203
224
|
};
|