@powerlines/core 0.44.0 → 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 (65) hide show
  1. package/dist/constants/index.cjs +2 -2
  2. package/dist/constants/index.mjs +2 -2
  3. package/dist/index.cjs +7 -10
  4. package/dist/index.d.cts +3 -4
  5. package/dist/index.d.mts +3 -4
  6. package/dist/index.mjs +4 -4
  7. package/dist/lib/index.cjs +1 -7
  8. package/dist/lib/index.d.cts +1 -2
  9. package/dist/lib/index.d.mts +1 -2
  10. package/dist/lib/index.mjs +2 -3
  11. package/dist/lib/unplugin/plugin.cjs +9 -11
  12. package/dist/lib/unplugin/plugin.d.cts.map +1 -1
  13. package/dist/lib/unplugin/plugin.d.mts.map +1 -1
  14. package/dist/lib/unplugin/plugin.mjs +9 -11
  15. package/dist/lib/unplugin/plugin.mjs.map +1 -1
  16. package/dist/lib/utilities/index.cjs +1 -1
  17. package/dist/lib/utilities/index.mjs +1 -1
  18. package/dist/lib/utilities/write-file.d.cts +1 -1
  19. package/dist/lib/utilities/write-file.d.mts +1 -1
  20. package/dist/lib/utilities/write-file.mjs.map +1 -1
  21. package/dist/plugin-utils/index.cjs +15 -2
  22. package/dist/plugin-utils/index.d.cts +2 -2
  23. package/dist/plugin-utils/index.d.mts +2 -2
  24. package/dist/plugin-utils/index.mjs +3 -3
  25. package/dist/plugin-utils/logging.cjs +325 -4
  26. package/dist/plugin-utils/logging.d.cts +77 -3
  27. package/dist/plugin-utils/logging.d.cts.map +1 -1
  28. package/dist/plugin-utils/logging.d.mts +77 -3
  29. package/dist/plugin-utils/logging.d.mts.map +1 -1
  30. package/dist/plugin-utils/logging.mjs +311 -4
  31. package/dist/plugin-utils/logging.mjs.map +1 -1
  32. package/dist/types/config.d.cts +11 -4
  33. package/dist/types/config.d.cts.map +1 -1
  34. package/dist/types/config.d.mts +11 -4
  35. package/dist/types/config.d.mts.map +1 -1
  36. package/dist/types/context.d.cts +17 -28
  37. package/dist/types/context.d.cts.map +1 -1
  38. package/dist/types/context.d.mts +17 -28
  39. package/dist/types/context.d.mts.map +1 -1
  40. package/dist/types/index.cjs +1 -0
  41. package/dist/types/index.d.cts +2 -2
  42. package/dist/types/index.d.mts +2 -2
  43. package/dist/types/index.mjs +3 -0
  44. package/dist/types/logging.cjs +48 -0
  45. package/dist/types/logging.d.cts +174 -0
  46. package/dist/types/logging.d.cts.map +1 -0
  47. package/dist/types/logging.d.mts +174 -0
  48. package/dist/types/logging.d.mts.map +1 -0
  49. package/dist/types/logging.mjs +45 -0
  50. package/dist/types/logging.mjs.map +1 -0
  51. package/package.json +74 -442
  52. package/dist/lib/logger.cjs +0 -106
  53. package/dist/lib/logger.d.cts +0 -42
  54. package/dist/lib/logger.d.cts.map +0 -1
  55. package/dist/lib/logger.d.mts +0 -42
  56. package/dist/lib/logger.d.mts.map +0 -1
  57. package/dist/lib/logger.mjs +0 -100
  58. package/dist/lib/logger.mjs.map +0 -1
  59. package/dist/types/log.cjs +0 -26
  60. package/dist/types/log.d.cts +0 -90
  61. package/dist/types/log.d.cts.map +0 -1
  62. package/dist/types/log.d.mts +0 -90
  63. package/dist/types/log.d.mts.map +0 -1
  64. package/dist/types/log.mjs +0 -25
  65. package/dist/types/log.mjs.map +0 -1
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_plugin_utils_paths = require('./paths.cjs');
3
+ const require_plugin_utils_format_package_json = require('./format-package-json.cjs');
3
4
  const require_plugin_utils_build_helpers = require('./build-helpers.cjs');
4
5
  const require_plugin_utils_helpers = require('./helpers.cjs');
5
6
  const require_plugin_utils_merge = require('./merge.cjs');
@@ -8,21 +9,28 @@ const require_plugin_utils_context_helpers = require('./context-helpers.cjs');
8
9
  const require_plugin_utils_docs_helper = require('./docs-helper.cjs');
9
10
  const require_plugin_utils_extend = require('./extend.cjs');
10
11
  const require_plugin_utils_filter = require('./filter.cjs');
11
- const require_plugin_utils_format_package_json = require('./format-package-json.cjs');
12
12
  const require_plugin_utils_get_config_path = require('./get-config-path.cjs');
13
13
  const require_plugin_utils_logging = require('./logging.cjs');
14
14
  const require_plugin_utils_modules = require('./modules.cjs');
15
15
 
16
16
  exports.addPluginHook = require_plugin_utils_helpers.addPluginHook;
17
+ exports.colorBackground = require_plugin_utils_logging.colorBackground;
18
+ exports.colorText = require_plugin_utils_logging.colorText;
17
19
  exports.combinePluginOptions = require_plugin_utils_combine_plugins.combinePluginOptions;
18
20
  exports.combinePlugins = require_plugin_utils_combine_plugins.combinePlugins;
21
+ exports.consoleLog = require_plugin_utils_logging.consoleLog;
22
+ exports.consoleLogger = require_plugin_utils_logging.consoleLogger;
19
23
  exports.createCodeFilter = require_plugin_utils_filter.createCodeFilter;
20
24
  exports.createFilter = require_plugin_utils_filter.createFilter;
21
25
  exports.createFilterForId = require_plugin_utils_filter.createFilterForId;
22
26
  exports.createFilterForTransform = require_plugin_utils_filter.createFilterForTransform;
23
27
  exports.createIdFilter = require_plugin_utils_filter.createIdFilter;
28
+ exports.createLogFn = require_plugin_utils_logging.createLogFn;
29
+ exports.createLogger = require_plugin_utils_logging.createLogger;
24
30
  exports.dedupeHooklist = require_plugin_utils_helpers.dedupeHooklist;
25
31
  exports.extend = require_plugin_utils_extend.extend;
32
+ exports.extendLogFn = require_plugin_utils_logging.extendLogFn;
33
+ exports.extendLogger = require_plugin_utils_logging.extendLogger;
26
34
  exports.extractPluginHook = require_plugin_utils_helpers.extractPluginHook;
27
35
  exports.findInvalidPluginConfig = require_plugin_utils_helpers.findInvalidPluginConfig;
28
36
  exports.formatPackageJson = require_plugin_utils_format_package_json.formatPackageJson;
@@ -31,6 +39,7 @@ exports.getDependencyConfig = require_plugin_utils_build_helpers.getDependencyCo
31
39
  exports.getDocsOutputPath = require_plugin_utils_docs_helper.getDocsOutputPath;
32
40
  exports.getHookHandler = require_plugin_utils_helpers.getHookHandler;
33
41
  exports.getOrganizationName = require_plugin_utils_context_helpers.getOrganizationName;
42
+ exports.getTextColor = require_plugin_utils_logging.getTextColor;
34
43
  exports.getWorkspaceName = require_plugin_utils_context_helpers.getWorkspaceName;
35
44
  exports.isBuiltinModule = require_plugin_utils_modules.isBuiltinModule;
36
45
  exports.isDuplicate = require_plugin_utils_helpers.isDuplicate;
@@ -44,6 +53,8 @@ exports.isPluginHookFunction = require_plugin_utils_helpers.isPluginHookFunction
44
53
  exports.isPluginHookObject = require_plugin_utils_helpers.isPluginHookObject;
45
54
  exports.isUnpluginHookField = require_plugin_utils_helpers.isUnpluginHookField;
46
55
  exports.isUnpluginHookKey = require_plugin_utils_helpers.isUnpluginHookKey;
56
+ exports.isValidLogLevel = require_plugin_utils_logging.isValidLogLevel;
57
+ exports.isValidLogLevelConfig = require_plugin_utils_logging.isValidLogLevelConfig;
47
58
  exports.isVerbose = require_plugin_utils_logging.isVerbose;
48
59
  exports.merge = require_plugin_utils_merge.merge;
49
60
  exports.mergeConfig = require_plugin_utils_merge.mergeConfig;
@@ -51,4 +62,6 @@ exports.normalizeFilter = require_plugin_utils_filter.normalizeFilter;
51
62
  exports.patternToCodeFilter = require_plugin_utils_filter.patternToCodeFilter;
52
63
  exports.patternToIdFilter = require_plugin_utils_filter.patternToIdFilter;
53
64
  exports.replacePathTokens = require_plugin_utils_paths.replacePathTokens;
54
- exports.resolveLogLevel = require_plugin_utils_logging.resolveLogLevel;
65
+ exports.resolveLogLevel = require_plugin_utils_logging.resolveLogLevel;
66
+ exports.withCustomLogger = require_plugin_utils_logging.withCustomLogger;
67
+ exports.withLogger = require_plugin_utils_logging.withLogger;
@@ -7,8 +7,8 @@ import { createCodeFilter, createFilter, createFilterForId, createFilterForTrans
7
7
  import { formatPackageJson } from "./format-package-json.cjs";
8
8
  import { getConfigPath } from "./get-config-path.cjs";
9
9
  import { GetHookHandlerReturnType, __ΩGetHookHandlerReturnType, addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.cjs";
10
- import { isVerbose, resolveLogLevel } from "./logging.cjs";
10
+ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger } from "./logging.cjs";
11
11
  import { MergeResult, __ΩMergeResult, merge, mergeConfig } from "./merge.cjs";
12
12
  import { isBuiltinModule } from "./modules.cjs";
13
13
  import { replacePathTokens } from "./paths.cjs";
14
- export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, combinePluginOptions, combinePlugins, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, dedupeHooklist, extend, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel };
14
+ export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel, withCustomLogger, withLogger };
@@ -7,8 +7,8 @@ import { createCodeFilter, createFilter, createFilterForId, createFilterForTrans
7
7
  import { formatPackageJson } from "./format-package-json.mjs";
8
8
  import { getConfigPath } from "./get-config-path.mjs";
9
9
  import { GetHookHandlerReturnType, __ΩGetHookHandlerReturnType, addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.mjs";
10
- import { isVerbose, resolveLogLevel } from "./logging.mjs";
10
+ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger } from "./logging.mjs";
11
11
  import { MergeResult, __ΩMergeResult, merge, mergeConfig } from "./merge.mjs";
12
12
  import { isBuiltinModule } from "./modules.mjs";
13
13
  import { replacePathTokens } from "./paths.mjs";
14
- export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, combinePluginOptions, combinePlugins, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, dedupeHooklist, extend, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel };
14
+ export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel, withCustomLogger, withLogger };
@@ -1,4 +1,5 @@
1
1
  import { replacePathTokens } from "./paths.mjs";
2
+ import { formatPackageJson } from "./format-package-json.mjs";
2
3
  import { getDependencyConfig } from "./build-helpers.mjs";
3
4
  import { addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.mjs";
4
5
  import { merge, mergeConfig } from "./merge.mjs";
@@ -7,9 +8,8 @@ import { getOrganizationName, getWorkspaceName } from "./context-helpers.mjs";
7
8
  import { getDocsOutputPath } from "./docs-helper.mjs";
8
9
  import { extend } from "./extend.mjs";
9
10
  import { createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, normalizeFilter, patternToCodeFilter, patternToIdFilter } from "./filter.mjs";
10
- import { formatPackageJson } from "./format-package-json.mjs";
11
11
  import { getConfigPath } from "./get-config-path.mjs";
12
- import { isVerbose, resolveLogLevel } from "./logging.mjs";
12
+ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger } from "./logging.mjs";
13
13
  import { isBuiltinModule } from "./modules.mjs";
14
14
 
15
- export { addPluginHook, combinePluginOptions, combinePlugins, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, dedupeHooklist, extend, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel };
15
+ export { addPluginHook, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel, withCustomLogger, withLogger };
@@ -1,10 +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');
3
5
  const require_log_level = require('../constants/log-level.cjs');
4
6
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
7
  let defu = require("defu");
6
8
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
7
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);
8
17
 
9
18
  //#region src/plugin-utils/logging.ts
10
19
  /**
@@ -34,7 +43,8 @@ function resolveLogLevel(logLevel, mode) {
34
43
  hooks: "trace",
35
44
  env: "trace",
36
45
  ipc: "trace",
37
- config: "trace"
46
+ config: "trace",
47
+ babel: "trace"
38
48
  };
39
49
  else if (logLevel === "silent") return {
40
50
  general: "silent",
@@ -45,7 +55,8 @@ function resolveLogLevel(logLevel, mode) {
45
55
  hooks: "silent",
46
56
  env: "silent",
47
57
  ipc: "silent",
48
- config: "silent"
58
+ config: "silent",
59
+ babel: "silent"
49
60
  };
50
61
  let defaultLogLevel;
51
62
  if (mode === "development") defaultLogLevel = require_log_level.DEFAULT_DEVELOPMENT_LOG_LEVEL;
@@ -60,12 +71,322 @@ function resolveLogLevel(logLevel, mode) {
60
71
  hooks: logLevel,
61
72
  env: defaultLogLevel.env,
62
73
  ipc: defaultLogLevel.ipc,
63
- config: defaultLogLevel.config
74
+ config: defaultLogLevel.config,
75
+ babel: logLevel
64
76
  };
65
77
  else if ((0, _stryke_type_checks_is_set_object.isSetObject)(logLevel)) return (0, defu.defu)(logLevel, defaultLogLevel);
66
78
  return defaultLogLevel;
67
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
+ };
68
376
 
69
377
  //#endregion
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;
70
389
  exports.isVerbose = isVerbose;
71
- exports.resolveLogLevel = resolveLogLevel;
390
+ exports.resolveLogLevel = resolveLogLevel;
391
+ exports.withCustomLogger = withCustomLogger;
392
+ exports.withLogger = withLogger;
@@ -1,6 +1,7 @@
1
- import { LogLevelResolvedConfig, LogLevelUserConfig } from "../types/log.cjs";
1
+ import { CustomLogger, LogCategory, LogFn, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMeta, Logger, LoggerMessage, LoggerOptions } from "../types/logging.cjs";
2
2
  import { UnresolvedContext } from "../types/context.cjs";
3
3
  import { Mode } from "../types/config.cjs";
4
+
4
5
  //#region src/plugin-utils/logging.d.ts
5
6
  /**
6
7
  * Determines if the provided log level is considered verbose (debug or trace).
@@ -23,7 +24,80 @@ declare function isVerbose(context: UnresolvedContext): boolean;
23
24
  * @param mode - The current mode of the application (e.g., "development", "test", "production"), which determines the default log levels.
24
25
  * @returns A LogLevelResolvedConfig object specifying the log level for each log category.
25
26
  */
26
- declare function resolveLogLevel(logLevel: LogLevelUserConfig, mode?: Mode): LogLevelResolvedConfig;
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;
27
101
  //#endregion
28
- export { isVerbose, resolveLogLevel };
102
+ export { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger };
29
103
  //# sourceMappingURL=logging.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.cts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;;;;AAoCA;;iBAAgB,SAAA,CAAU,QAAA;;;AAQ1B;;;;iBAAgB,SAAA,CAAU,OAAA,EAAS,iBAAA;AAyBnC;;;;;;;AAAA,iBAAgB,eAAA,CACd,QAAA,EAAU,kBAAA,EACV,IAAA,GAAO,IAAA,GACN,sBAAA"}
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"}