@powerlines/core 0.43.31 → 0.44.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.
Files changed (69) hide show
  1. package/dist/constants/index.cjs +5 -1
  2. package/dist/constants/index.d.cts +2 -1
  3. package/dist/constants/index.d.mts +2 -1
  4. package/dist/constants/index.mjs +3 -2
  5. package/dist/constants/log-level.cjs +43 -0
  6. package/dist/constants/log-level.d.cts +40 -0
  7. package/dist/constants/log-level.d.cts.map +1 -0
  8. package/dist/constants/log-level.d.mts +40 -0
  9. package/dist/constants/log-level.d.mts.map +1 -0
  10. package/dist/constants/log-level.mjs +41 -0
  11. package/dist/constants/log-level.mjs.map +1 -0
  12. package/dist/index.cjs +6 -6
  13. package/dist/index.d.cts +3 -3
  14. package/dist/index.d.mts +3 -3
  15. package/dist/index.mjs +3 -2
  16. package/dist/lib/index.cjs +0 -6
  17. package/dist/lib/index.d.cts +1 -2
  18. package/dist/lib/index.d.mts +1 -2
  19. package/dist/lib/index.mjs +1 -2
  20. package/dist/lib/unplugin/plugin.cjs +9 -11
  21. package/dist/lib/unplugin/plugin.d.cts.map +1 -1
  22. package/dist/lib/unplugin/plugin.d.mts.map +1 -1
  23. package/dist/lib/unplugin/plugin.mjs +9 -11
  24. package/dist/lib/unplugin/plugin.mjs.map +1 -1
  25. package/dist/lib/utilities/write-file.cjs +1 -2
  26. package/dist/lib/utilities/write-file.d.cts +1 -1
  27. package/dist/lib/utilities/write-file.d.cts.map +1 -1
  28. package/dist/lib/utilities/write-file.d.mts +1 -1
  29. package/dist/lib/utilities/write-file.d.mts.map +1 -1
  30. package/dist/lib/utilities/write-file.mjs +1 -2
  31. package/dist/lib/utilities/write-file.mjs.map +1 -1
  32. package/dist/plugin-utils/index.cjs +15 -1
  33. package/dist/plugin-utils/index.d.cts +2 -2
  34. package/dist/plugin-utils/index.d.mts +2 -2
  35. package/dist/plugin-utils/index.mjs +2 -2
  36. package/dist/plugin-utils/logging.cjs +375 -1
  37. package/dist/plugin-utils/logging.d.cts +85 -1
  38. package/dist/plugin-utils/logging.d.cts.map +1 -1
  39. package/dist/plugin-utils/logging.d.mts +85 -1
  40. package/dist/plugin-utils/logging.d.mts.map +1 -1
  41. package/dist/plugin-utils/logging.mjs +360 -1
  42. package/dist/plugin-utils/logging.mjs.map +1 -1
  43. package/dist/types/config.d.cts +33 -28
  44. package/dist/types/config.d.cts.map +1 -1
  45. package/dist/types/config.d.mts +33 -28
  46. package/dist/types/config.d.mts.map +1 -1
  47. package/dist/types/context.d.cts +20 -34
  48. package/dist/types/context.d.cts.map +1 -1
  49. package/dist/types/context.d.mts +20 -34
  50. package/dist/types/context.d.mts.map +1 -1
  51. package/dist/types/index.cjs +1 -0
  52. package/dist/types/index.d.cts +2 -1
  53. package/dist/types/index.d.mts +2 -1
  54. package/dist/types/index.mjs +3 -0
  55. package/dist/types/logging.cjs +48 -0
  56. package/dist/types/logging.d.cts +174 -0
  57. package/dist/types/logging.d.cts.map +1 -0
  58. package/dist/types/logging.d.mts +174 -0
  59. package/dist/types/logging.d.mts.map +1 -0
  60. package/dist/types/logging.mjs +45 -0
  61. package/dist/types/logging.mjs.map +1 -0
  62. package/package.json +74 -442
  63. package/dist/lib/logger.cjs +0 -100
  64. package/dist/lib/logger.d.cts +0 -54
  65. package/dist/lib/logger.d.cts.map +0 -1
  66. package/dist/lib/logger.d.mts +0 -54
  67. package/dist/lib/logger.d.mts.map +0 -1
  68. package/dist/lib/logger.mjs +0 -94
  69. package/dist/lib/logger.mjs.map +0 -1
@@ -1,6 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_logging = require('../types/logging.cjs');
4
+ const require_environments = require('../constants/environments.cjs');
5
+ const require_log_level = require('../constants/log-level.cjs');
6
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
7
+ let defu = require("defu");
8
+ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
3
9
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
10
+ let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
11
+ let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
12
+ let _storm_software_config_tools_logger = require("@storm-software/config-tools/logger");
13
+ let _storm_software_config_tools_utilities_colors = require("@storm-software/config-tools/utilities/colors");
14
+ let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
15
+ let chalk = require("chalk");
16
+ chalk = require_runtime.__toESM(chalk, 1);
4
17
 
5
18
  //#region src/plugin-utils/logging.ts
6
19
  /**
@@ -13,6 +26,367 @@ function isVerbose(logLevelOrContext) {
13
26
  const level = (0, _stryke_type_checks_is_string.isString)(logLevelOrContext) ? logLevelOrContext : logLevelOrContext.config.logLevel;
14
27
  return level === "debug" || level === "trace";
15
28
  }
29
+ /**
30
+ * Resolves the log level configuration based on the provided log level and mode, returning a complete LogLevelResolvedConfig object that specifies the log level for each log category.
31
+ *
32
+ * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.
33
+ * @param mode - The current mode of the application (e.g., "development", "test", "production"), which determines the default log levels.
34
+ * @returns A LogLevelResolvedConfig object specifying the log level for each log category.
35
+ */
36
+ function resolveLogLevel(logLevel, mode) {
37
+ if (logLevel === "trace") return {
38
+ general: "trace",
39
+ fs: "trace",
40
+ performance: "trace",
41
+ network: "trace",
42
+ plugins: "trace",
43
+ hooks: "trace",
44
+ env: "trace",
45
+ ipc: "trace",
46
+ config: "trace",
47
+ babel: "trace"
48
+ };
49
+ else if (logLevel === "silent") return {
50
+ general: "silent",
51
+ fs: "silent",
52
+ performance: "silent",
53
+ network: "silent",
54
+ plugins: "silent",
55
+ hooks: "silent",
56
+ env: "silent",
57
+ ipc: "silent",
58
+ config: "silent",
59
+ babel: "silent"
60
+ };
61
+ let defaultLogLevel;
62
+ if (mode === "development") defaultLogLevel = require_log_level.DEFAULT_DEVELOPMENT_LOG_LEVEL;
63
+ else if (mode === "test") defaultLogLevel = require_log_level.DEFAULT_TEST_LOG_LEVEL;
64
+ else defaultLogLevel = require_log_level.DEFAULT_PRODUCTION_LOG_LEVEL;
65
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(logLevel)) return {
66
+ general: logLevel,
67
+ fs: defaultLogLevel.fs,
68
+ performance: logLevel,
69
+ network: defaultLogLevel.network,
70
+ plugins: logLevel,
71
+ hooks: logLevel,
72
+ env: defaultLogLevel.env,
73
+ ipc: defaultLogLevel.ipc,
74
+ config: defaultLogLevel.config,
75
+ babel: logLevel
76
+ };
77
+ else if ((0, _stryke_type_checks_is_set_object.isSetObject)(logLevel)) return (0, defu.defu)(logLevel, defaultLogLevel);
78
+ return defaultLogLevel;
79
+ }
80
+ const BADGE_COLORS = [
81
+ "#00A0DD",
82
+ "#6FCE4E",
83
+ "#FBBF24",
84
+ "#F43F5E",
85
+ "#3B82F6",
86
+ "#A855F7",
87
+ "#469592",
88
+ "#288EDF",
89
+ "#D8B4FE",
90
+ "#10B981",
91
+ "#EF4444",
92
+ "#F0EC56",
93
+ "#F472B6",
94
+ "#22D3EE",
95
+ "#EAB308",
96
+ "#84CC16",
97
+ "#F87171",
98
+ "#0EA5E9",
99
+ "#D946EF",
100
+ "#FACC15",
101
+ "#34D399",
102
+ "#8B5CF6"
103
+ ];
104
+ const BRAND_COLOR = (0, _storm_software_config_tools_utilities_colors.getColor)("brand");
105
+ /**
106
+ * Generate a consistent color based on the input text.
107
+ *
108
+ * @param text - The input text to generate the color from.
109
+ * @return A hexadecimal color string.
110
+ */
111
+ const getTextColor = (text) => {
112
+ return BADGE_COLORS[text.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0];
113
+ };
114
+ /**
115
+ * Generate a consistent color based on the input text.
116
+ *
117
+ * @param text - The input text to generate the color from.
118
+ * @return A hexadecimal color string.
119
+ */
120
+ const colorText = (text) => {
121
+ const title = (0, _stryke_string_format_title_case.titleCase)(text);
122
+ return chalk.default.hex(getTextColor(title))(title);
123
+ };
124
+ /**
125
+ * Generate a consistent color based on the input text.
126
+ *
127
+ * @param text - The input text to generate the color from.
128
+ * @return A hexadecimal color string.
129
+ */
130
+ const colorBackground = (text) => {
131
+ const title = (0, _stryke_string_format_title_case.titleCase)(text);
132
+ return chalk.default.inverse.hex(getTextColor(title))(` ${title} `);
133
+ };
134
+ const consoleLog = (meta, ...args) => (0, _storm_software_config_tools_logger.getLogFn)((0, _storm_software_config_tools_logger.getLogLevel)(meta.type), { logLevel: "trace" })(`${meta.name ? chalk.default.bold.hex(BRAND_COLOR)((0, _stryke_string_format_kebab_case.kebabCase)(meta.name)) : ""}${meta.command ? chalk.default.hex(BRAND_COLOR)(` (${meta.command})`) : ""}${meta.name ? chalk.default.grey(" > ") : ""}${(meta.source || meta.plugin) && (!meta.name || (0, _stryke_string_format_kebab_case.kebabCase)(meta.source || meta.plugin) !== (0, _stryke_string_format_kebab_case.kebabCase)(meta.name)) ? `${chalk.default.bold.hex(BRAND_COLOR)((0, _stryke_string_format_kebab_case.kebabCase)(meta.source || meta.plugin))}${chalk.default.grey(" > ")}` : ""}${meta.environment && (0, _stryke_string_format_kebab_case.kebabCase)(meta.environment) !== "default" ? `${chalk.default.bold.hex(BRAND_COLOR)((0, _stryke_string_format_kebab_case.kebabCase)(meta.environment))}${chalk.default.grey(" > ")}` : ""}${meta.category && meta.category !== require_logging.LogCategories.GENERAL ? ` ${colorBackground((0, _stryke_string_format_kebab_case.kebabCase)(meta.category))} ` : ""}${args.join(" ")} `.trim());
135
+ function isValidLogLevel(logLevel, type) {
136
+ if (logLevel === require_logging.LogLevels.SILENT) return false;
137
+ return require_logging.LOG_LEVELS.indexOf(logLevel) >= require_logging.LOG_LEVELS.indexOf(type);
138
+ }
139
+ function isValidLogLevelConfig(type, logLevel, category = require_logging.LogCategories.GENERAL) {
140
+ return isValidLogLevel(logLevel[category], type);
141
+ }
142
+ /**
143
+ * Create a logging function with a specific name and options.
144
+ *
145
+ * @param name - The name of the logging function.
146
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.
147
+ * @returns A logging function.
148
+ */
149
+ const createLogFn = (name, options) => {
150
+ const logLevel = resolveLogLevel(options.logLevel, options.mode);
151
+ return (meta, ...args) => {
152
+ const logMeta = (0, _stryke_type_checks_is_set_object.isSetObject)(meta) ? {
153
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
154
+ timestamp: Date.now(),
155
+ category: require_logging.LogCategories.GENERAL,
156
+ ...options,
157
+ ...meta,
158
+ name
159
+ } : {
160
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
161
+ timestamp: Date.now(),
162
+ category: require_logging.LogCategories.GENERAL,
163
+ ...options,
164
+ type: meta,
165
+ name
166
+ };
167
+ if (isValidLogLevelConfig(logMeta.type, logLevel, logMeta.category ? logMeta.category : require_logging.LogCategories.GENERAL)) consoleLog(logMeta, ...args);
168
+ };
169
+ };
170
+ const validateLogger = (type, name, options, callback) => {
171
+ const logLevel = resolveLogLevel(options.logLevel, options.mode);
172
+ return (message) => {
173
+ const params = (0, _stryke_type_checks_is_set_string.isSetString)(message) ? {
174
+ name,
175
+ plugin: options.plugin,
176
+ meta: {
177
+ type,
178
+ name,
179
+ category: require_logging.LogCategories.GENERAL,
180
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
181
+ timestamp: Date.now(),
182
+ ...options
183
+ },
184
+ message
185
+ } : {
186
+ name,
187
+ plugin: options.plugin,
188
+ ...message,
189
+ meta: {
190
+ type,
191
+ name,
192
+ category: require_logging.LogCategories.GENERAL,
193
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
194
+ timestamp: Date.now(),
195
+ plugin: message.plugin,
196
+ ...options,
197
+ ...message.meta
198
+ }
199
+ };
200
+ if (isValidLogLevelConfig(type, logLevel, params.meta.category)) callback(params);
201
+ };
202
+ };
203
+ const validateCustomLogger = (type, name, options, callback, customCallback) => {
204
+ const logLevel = resolveLogLevel(options.logLevel, options.mode);
205
+ return (message) => {
206
+ const params = (0, _stryke_type_checks_is_set_string.isSetString)(message) ? {
207
+ name,
208
+ plugin: options.plugin,
209
+ meta: {
210
+ type,
211
+ name,
212
+ category: require_logging.LogCategories.GENERAL,
213
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
214
+ timestamp: Date.now(),
215
+ ...options
216
+ },
217
+ message
218
+ } : {
219
+ name,
220
+ plugin: options.plugin,
221
+ ...message,
222
+ meta: {
223
+ type,
224
+ name,
225
+ category: require_logging.LogCategories.GENERAL,
226
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
227
+ timestamp: Date.now(),
228
+ plugin: message.plugin,
229
+ ...options,
230
+ ...message.meta
231
+ }
232
+ };
233
+ if (isValidLogLevelConfig(type, logLevel, params.meta.category)) {
234
+ callback?.(params);
235
+ customCallback?.(params);
236
+ }
237
+ };
238
+ };
239
+ /**
240
+ * Create a logging function with a specific name and options.
241
+ *
242
+ * @param logger - The original logger to wrap with the custom logger.
243
+ * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
244
+ * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.
245
+ */
246
+ const withLogger = (logger, secondaryLogger) => {
247
+ const options = {
248
+ ...secondaryLogger.options,
249
+ ...logger.options
250
+ };
251
+ return {
252
+ options,
253
+ error: validateLogger("error", options.name, options, (message) => {
254
+ logger.error?.(message);
255
+ secondaryLogger.error?.(message);
256
+ }),
257
+ warn: validateLogger("warn", options.name, options, (message) => {
258
+ logger.warn?.(message);
259
+ secondaryLogger.warn?.(message);
260
+ }),
261
+ info: validateLogger("info", options.name, options, (message) => {
262
+ logger.info?.(message);
263
+ secondaryLogger.info?.(message);
264
+ }),
265
+ debug: validateLogger("debug", options.name, options, (message) => {
266
+ logger.debug?.(message);
267
+ secondaryLogger.debug?.(message);
268
+ }),
269
+ trace: validateLogger("trace", options.name, options, (message) => {
270
+ logger.trace?.(message);
271
+ secondaryLogger.trace?.(message);
272
+ })
273
+ };
274
+ };
275
+ /**
276
+ * Create a logging function with a specific name and options.
277
+ *
278
+ * @param logger - The original logger to wrap with the custom logger.
279
+ * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
280
+ * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.
281
+ */
282
+ const withCustomLogger = (logger, customLogger) => {
283
+ return {
284
+ options: logger.options,
285
+ error: validateCustomLogger("error", logger.options.name, logger.options, logger.error.bind(logger), customLogger.error?.bind(customLogger)),
286
+ warn: validateCustomLogger("warn", logger.options.name, logger.options, logger.warn.bind(logger), customLogger.warn?.bind(customLogger)),
287
+ info: validateCustomLogger("info", logger.options.name, logger.options, logger.info.bind(logger), customLogger.info?.bind(customLogger)),
288
+ debug: validateCustomLogger("debug", logger.options.name, logger.options, logger.debug.bind(logger), customLogger.debug?.bind(customLogger)),
289
+ trace: validateCustomLogger("trace", logger.options.name, logger.options, logger.trace.bind(logger), customLogger.trace?.bind(customLogger))
290
+ };
291
+ };
292
+ const consoleLogger = (type, message) => consoleLog((0, _stryke_type_checks_is_set_string.isSetString)(message) ? {
293
+ type,
294
+ category: require_logging.LogCategories.GENERAL,
295
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
296
+ timestamp: Date.now()
297
+ } : {
298
+ type,
299
+ category: require_logging.LogCategories.GENERAL,
300
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
301
+ timestamp: Date.now(),
302
+ ...message
303
+ }, (0, _stryke_type_checks_is_set_string.isSetString)(message) ? message : message.message);
304
+ /**
305
+ * Create a logging function with a specific name and options.
306
+ *
307
+ * @param name - The name of the logging function.
308
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.
309
+ * @returns A logging function.
310
+ */
311
+ const createLogger = (name, options, callback = consoleLogger) => {
312
+ return {
313
+ options: {
314
+ ...options,
315
+ name
316
+ },
317
+ error: validateLogger("error", name, {
318
+ ...options,
319
+ name
320
+ }, (message) => callback("error", message)),
321
+ warn: validateLogger("warn", name, {
322
+ ...options,
323
+ name
324
+ }, (message) => callback("warn", message)),
325
+ info: validateLogger("info", name, {
326
+ ...options,
327
+ name
328
+ }, (message) => callback("info", message)),
329
+ debug: validateLogger("debug", name, {
330
+ ...options,
331
+ name
332
+ }, (message) => callback("debug", message)),
333
+ trace: validateLogger("trace", name, {
334
+ ...options,
335
+ name
336
+ }, (message) => callback("trace", message))
337
+ };
338
+ };
339
+ /**
340
+ * Extend a logging function with a specific name, adding a colored badge to the log output.
341
+ *
342
+ * @param logFn - The original logging function to extend.
343
+ * @param options - The overlay metadata to use for the badge in the log output.
344
+ * @returns A new logging function that includes the badge in its output.
345
+ */
346
+ const extendLogFn = (logFn, options) => {
347
+ return (meta, ...args) => options.source || options.category ? logFn((0, _stryke_type_checks_is_set_object.isSetObject)(meta) ? {
348
+ ...options,
349
+ ...meta
350
+ } : {
351
+ ...options,
352
+ type: meta
353
+ }, `${colorBackground(String(options.source || options.category))} ${args.filter(Boolean).map((arg) => String(arg).trim()).join(" ")} `) : logFn(meta, ...args);
354
+ };
355
+ /**
356
+ * Extend a logger with a specific name and options, adding a colored badge to the log output for each log message generated by the logger.
357
+ *
358
+ * @param logger - The original logger to extend.
359
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the extended logger.
360
+ * @returns A new logger that includes the badge in its output for each log message.
361
+ */
362
+ const extendLogger = (logger, options) => {
363
+ const opts = {
364
+ ...logger.options,
365
+ ...options
366
+ };
367
+ return {
368
+ options: opts,
369
+ error: validateLogger("error", opts.name, opts, logger.error.bind(logger)),
370
+ warn: validateLogger("warn", opts.name, opts, logger.warn.bind(logger)),
371
+ info: validateLogger("info", opts.name, opts, logger.info.bind(logger)),
372
+ debug: validateLogger("debug", opts.name, opts, logger.debug.bind(logger)),
373
+ trace: validateLogger("trace", opts.name, opts, logger.trace.bind(logger))
374
+ };
375
+ };
16
376
 
17
377
  //#endregion
18
- exports.isVerbose = isVerbose;
378
+ exports.colorBackground = colorBackground;
379
+ exports.colorText = colorText;
380
+ exports.consoleLog = consoleLog;
381
+ exports.consoleLogger = consoleLogger;
382
+ exports.createLogFn = createLogFn;
383
+ exports.createLogger = createLogger;
384
+ exports.extendLogFn = extendLogFn;
385
+ exports.extendLogger = extendLogger;
386
+ exports.getTextColor = getTextColor;
387
+ exports.isValidLogLevel = isValidLogLevel;
388
+ exports.isValidLogLevelConfig = isValidLogLevelConfig;
389
+ exports.isVerbose = isVerbose;
390
+ exports.resolveLogLevel = resolveLogLevel;
391
+ exports.withCustomLogger = withCustomLogger;
392
+ exports.withLogger = withLogger;
@@ -1,4 +1,7 @@
1
+ import { CustomLogger, LogCategory, LogFn, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMeta, Logger, LoggerMessage, LoggerOptions } from "../types/logging.cjs";
1
2
  import { UnresolvedContext } from "../types/context.cjs";
3
+ import { Mode } from "../types/config.cjs";
4
+
2
5
  //#region src/plugin-utils/logging.d.ts
3
6
  /**
4
7
  * Determines if the provided log level is considered verbose (debug or trace).
@@ -14,6 +17,87 @@ declare function isVerbose(logLevel: string): boolean;
14
17
  * @returns True if the log level is "debug" or "trace", false otherwise.
15
18
  */
16
19
  declare function isVerbose(context: UnresolvedContext): boolean;
20
+ /**
21
+ * Resolves the log level configuration based on the provided log level and mode, returning a complete LogLevelResolvedConfig object that specifies the log level for each log category.
22
+ *
23
+ * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.
24
+ * @param mode - The current mode of the application (e.g., "development", "test", "production"), which determines the default log levels.
25
+ * @returns A LogLevelResolvedConfig object specifying the log level for each log category.
26
+ */
27
+ declare function resolveLogLevel(logLevel?: LogLevelUserConfig, mode?: Mode): LogLevelResolvedConfig;
28
+ /**
29
+ * Generate a consistent color based on the input text.
30
+ *
31
+ * @param text - The input text to generate the color from.
32
+ * @return A hexadecimal color string.
33
+ */
34
+ declare const getTextColor: (text: string) => string;
35
+ /**
36
+ * Generate a consistent color based on the input text.
37
+ *
38
+ * @param text - The input text to generate the color from.
39
+ * @return A hexadecimal color string.
40
+ */
41
+ declare const colorText: (text: string) => string;
42
+ /**
43
+ * Generate a consistent color based on the input text.
44
+ *
45
+ * @param text - The input text to generate the color from.
46
+ * @return A hexadecimal color string.
47
+ */
48
+ declare const colorBackground: (text: string) => string;
49
+ declare const consoleLog: (meta: LogMeta, ...args: string[]) => void;
50
+ declare function isValidLogLevel(logLevel: LogLevel, type: LogLevel): boolean;
51
+ declare function isValidLogLevelConfig(type: LogLevel, logLevel: LogLevelResolvedConfig, category?: LogCategory): boolean;
52
+ /**
53
+ * Create a logging function with a specific name and options.
54
+ *
55
+ * @param name - The name of the logging function.
56
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.
57
+ * @returns A logging function.
58
+ */
59
+ declare const createLogFn: (name: string, options: LogFnOptions) => LogFn;
60
+ /**
61
+ * Create a logging function with a specific name and options.
62
+ *
63
+ * @param logger - The original logger to wrap with the custom logger.
64
+ * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
65
+ * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.
66
+ */
67
+ declare const withLogger: (logger: Logger, secondaryLogger: Logger) => Logger;
68
+ /**
69
+ * Create a logging function with a specific name and options.
70
+ *
71
+ * @param logger - The original logger to wrap with the custom logger.
72
+ * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
73
+ * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.
74
+ */
75
+ declare const withCustomLogger: (logger: Logger, customLogger: CustomLogger) => Logger;
76
+ declare const consoleLogger: (type: LogLevel, message: string | LoggerMessage) => void;
77
+ /**
78
+ * Create a logging function with a specific name and options.
79
+ *
80
+ * @param name - The name of the logging function.
81
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.
82
+ * @returns A logging function.
83
+ */
84
+ declare const createLogger: (name: string, options: LoggerOptions, callback?: (type: LogLevel, message: string | LoggerMessage) => void) => Logger;
85
+ /**
86
+ * Extend a logging function with a specific name, adding a colored badge to the log output.
87
+ *
88
+ * @param logFn - The original logging function to extend.
89
+ * @param options - The overlay metadata to use for the badge in the log output.
90
+ * @returns A new logging function that includes the badge in its output.
91
+ */
92
+ declare const extendLogFn: (logFn: LogFn, options: LogFnOptions) => LogFn;
93
+ /**
94
+ * Extend a logger with a specific name and options, adding a colored badge to the log output for each log message generated by the logger.
95
+ *
96
+ * @param logger - The original logger to extend.
97
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the extended logger.
98
+ * @returns A new logger that includes the badge in its output for each log message.
99
+ */
100
+ declare const extendLogger: (logger: Logger, options: LoggerOptions) => Logger;
17
101
  //#endregion
18
- export { isVerbose };
102
+ export { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger };
19
103
  //# sourceMappingURL=logging.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.cts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;AA2BA;;;iBAAgB,SAAA,CAAU,QAAA;;AAQ1B;;;;;iBAAgB,SAAA,CAAU,OAAA,EAAS,iBAAA"}
1
+ {"version":3,"file":"logging.d.cts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;;AA2DA;;;;;iBAAgB,SAAA,CAAU,QAAA;;;;;AAiC1B;;iBAzBgB,SAAA,CAAU,OAAA,EAAS,iBAAA;;;;;;;;iBAyBnB,eAAA,CACd,QAAA,GAAW,kBAAA,EACX,IAAA,GAAO,IAAA,GACN,sBAAA;;;;;AA2FH;;cAAa,YAAA,GAAgB,IAAA;;;AAiB7B;;;;cAAa,SAAA,GAAa,IAAA;AAY1B;;;;;AAMA;AANA,cAAa,eAAA,GAAmB,IAAA;AAAA,cAMnB,UAAA,GAAc,IAAA,EAAM,OAAA,KAAY,IAAA;AAAA,iBA2B7B,eAAA,CAAgB,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAA;AAAA,iBAQ1C,qBAAA,CACd,IAAA,EAAM,QAAA,EACN,QAAA,EAAU,sBAAA,EACV,QAAA,GAAU,WAAA;;;;;AAXZ;;;cAuBa,WAAA,GAAe,IAAA,UAAc,OAAA,EAAS,YAAA,KAAe,KAAA;;;;;;;AAflE;cAoJa,UAAA,GAAc,MAAA,EAAQ,MAAA,EAAQ,eAAA,EAAiB,MAAA,KAAS,MAAA;;;;;;;;cA4DxD,gBAAA,GACX,MAAA,EAAQ,MAAA,EACR,YAAA,EAAc,YAAA,KACb,MAAA;AAAA,cAyCU,aAAA,GACX,IAAA,EAAM,QAAA,EACN,OAAA,WAAkB,aAAA;;;;;;AA/OpB;;cA0Qa,YAAA,GACX,IAAA,UACA,OAAA,EAAS,aAAA,EACT,QAAA,IACE,IAAA,EAAM,QAAA,EACN,OAAA,WAAkB,aAAA,cAEnB,MAAA;;;;;;;;cA4BU,WAAA,GAAe,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,YAAA,KAAe,KAAA;;;;;;;;cAsBrD,YAAA,GACX,MAAA,EAAQ,MAAA,EACR,OAAA,EAAS,aAAA,KACR,MAAA"}
@@ -1,4 +1,7 @@
1
+ import { CustomLogger, LogCategory, LogFn, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMeta, Logger, LoggerMessage, LoggerOptions } from "../types/logging.mjs";
1
2
  import { UnresolvedContext } from "../types/context.mjs";
3
+ import { Mode } from "../types/config.mjs";
4
+
2
5
  //#region src/plugin-utils/logging.d.ts
3
6
  /**
4
7
  * Determines if the provided log level is considered verbose (debug or trace).
@@ -14,6 +17,87 @@ declare function isVerbose(logLevel: string): boolean;
14
17
  * @returns True if the log level is "debug" or "trace", false otherwise.
15
18
  */
16
19
  declare function isVerbose(context: UnresolvedContext): boolean;
20
+ /**
21
+ * Resolves the log level configuration based on the provided log level and mode, returning a complete LogLevelResolvedConfig object that specifies the log level for each log category.
22
+ *
23
+ * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.
24
+ * @param mode - The current mode of the application (e.g., "development", "test", "production"), which determines the default log levels.
25
+ * @returns A LogLevelResolvedConfig object specifying the log level for each log category.
26
+ */
27
+ declare function resolveLogLevel(logLevel?: LogLevelUserConfig, mode?: Mode): LogLevelResolvedConfig;
28
+ /**
29
+ * Generate a consistent color based on the input text.
30
+ *
31
+ * @param text - The input text to generate the color from.
32
+ * @return A hexadecimal color string.
33
+ */
34
+ declare const getTextColor: (text: string) => string;
35
+ /**
36
+ * Generate a consistent color based on the input text.
37
+ *
38
+ * @param text - The input text to generate the color from.
39
+ * @return A hexadecimal color string.
40
+ */
41
+ declare const colorText: (text: string) => string;
42
+ /**
43
+ * Generate a consistent color based on the input text.
44
+ *
45
+ * @param text - The input text to generate the color from.
46
+ * @return A hexadecimal color string.
47
+ */
48
+ declare const colorBackground: (text: string) => string;
49
+ declare const consoleLog: (meta: LogMeta, ...args: string[]) => void;
50
+ declare function isValidLogLevel(logLevel: LogLevel, type: LogLevel): boolean;
51
+ declare function isValidLogLevelConfig(type: LogLevel, logLevel: LogLevelResolvedConfig, category?: LogCategory): boolean;
52
+ /**
53
+ * Create a logging function with a specific name and options.
54
+ *
55
+ * @param name - The name of the logging function.
56
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.
57
+ * @returns A logging function.
58
+ */
59
+ declare const createLogFn: (name: string, options: LogFnOptions) => LogFn;
60
+ /**
61
+ * Create a logging function with a specific name and options.
62
+ *
63
+ * @param logger - The original logger to wrap with the custom logger.
64
+ * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
65
+ * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.
66
+ */
67
+ declare const withLogger: (logger: Logger, secondaryLogger: Logger) => Logger;
68
+ /**
69
+ * Create a logging function with a specific name and options.
70
+ *
71
+ * @param logger - The original logger to wrap with the custom logger.
72
+ * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
73
+ * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.
74
+ */
75
+ declare const withCustomLogger: (logger: Logger, customLogger: CustomLogger) => Logger;
76
+ declare const consoleLogger: (type: LogLevel, message: string | LoggerMessage) => void;
77
+ /**
78
+ * Create a logging function with a specific name and options.
79
+ *
80
+ * @param name - The name of the logging function.
81
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.
82
+ * @returns A logging function.
83
+ */
84
+ declare const createLogger: (name: string, options: LoggerOptions, callback?: (type: LogLevel, message: string | LoggerMessage) => void) => Logger;
85
+ /**
86
+ * Extend a logging function with a specific name, adding a colored badge to the log output.
87
+ *
88
+ * @param logFn - The original logging function to extend.
89
+ * @param options - The overlay metadata to use for the badge in the log output.
90
+ * @returns A new logging function that includes the badge in its output.
91
+ */
92
+ declare const extendLogFn: (logFn: LogFn, options: LogFnOptions) => LogFn;
93
+ /**
94
+ * Extend a logger with a specific name and options, adding a colored badge to the log output for each log message generated by the logger.
95
+ *
96
+ * @param logger - The original logger to extend.
97
+ * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the extended logger.
98
+ * @returns A new logger that includes the badge in its output for each log message.
99
+ */
100
+ declare const extendLogger: (logger: Logger, options: LoggerOptions) => Logger;
17
101
  //#endregion
18
- export { isVerbose };
102
+ export { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger };
19
103
  //# sourceMappingURL=logging.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.mts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;AA2BA;;;iBAAgB,SAAA,CAAU,QAAA;;AAQ1B;;;;;iBAAgB,SAAA,CAAU,OAAA,EAAS,iBAAA"}
1
+ {"version":3,"file":"logging.d.mts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;;AA2DA;;;;;iBAAgB,SAAA,CAAU,QAAA;;;;;AAiC1B;;iBAzBgB,SAAA,CAAU,OAAA,EAAS,iBAAA;;;;;;;;iBAyBnB,eAAA,CACd,QAAA,GAAW,kBAAA,EACX,IAAA,GAAO,IAAA,GACN,sBAAA;;;;;AA2FH;;cAAa,YAAA,GAAgB,IAAA;;;AAiB7B;;;;cAAa,SAAA,GAAa,IAAA;AAY1B;;;;;AAMA;AANA,cAAa,eAAA,GAAmB,IAAA;AAAA,cAMnB,UAAA,GAAc,IAAA,EAAM,OAAA,KAAY,IAAA;AAAA,iBA2B7B,eAAA,CAAgB,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAA;AAAA,iBAQ1C,qBAAA,CACd,IAAA,EAAM,QAAA,EACN,QAAA,EAAU,sBAAA,EACV,QAAA,GAAU,WAAA;;;;;AAXZ;;;cAuBa,WAAA,GAAe,IAAA,UAAc,OAAA,EAAS,YAAA,KAAe,KAAA;;;;;;;AAflE;cAoJa,UAAA,GAAc,MAAA,EAAQ,MAAA,EAAQ,eAAA,EAAiB,MAAA,KAAS,MAAA;;;;;;;;cA4DxD,gBAAA,GACX,MAAA,EAAQ,MAAA,EACR,YAAA,EAAc,YAAA,KACb,MAAA;AAAA,cAyCU,aAAA,GACX,IAAA,EAAM,QAAA,EACN,OAAA,WAAkB,aAAA;;;;;;AA/OpB;;cA0Qa,YAAA,GACX,IAAA,UACA,OAAA,EAAS,aAAA,EACT,QAAA,IACE,IAAA,EAAM,QAAA,EACN,OAAA,WAAkB,aAAA,cAEnB,MAAA;;;;;;;;cA4BU,WAAA,GAAe,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,YAAA,KAAe,KAAA;;;;;;;;cAsBrD,YAAA,GACX,MAAA,EAAQ,MAAA,EACR,OAAA,EAAS,aAAA,KACR,MAAA"}