@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.
- package/dist/constants/index.cjs +2 -2
- package/dist/constants/index.mjs +2 -2
- package/dist/index.cjs +7 -10
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.mjs +4 -4
- package/dist/lib/index.cjs +1 -7
- package/dist/lib/index.d.cts +1 -2
- package/dist/lib/index.d.mts +1 -2
- package/dist/lib/index.mjs +2 -3
- package/dist/lib/unplugin/plugin.cjs +9 -11
- package/dist/lib/unplugin/plugin.d.cts.map +1 -1
- package/dist/lib/unplugin/plugin.d.mts.map +1 -1
- package/dist/lib/unplugin/plugin.mjs +9 -11
- package/dist/lib/unplugin/plugin.mjs.map +1 -1
- package/dist/lib/utilities/index.cjs +1 -1
- package/dist/lib/utilities/index.mjs +1 -1
- package/dist/lib/utilities/write-file.d.cts +1 -1
- package/dist/lib/utilities/write-file.d.mts +1 -1
- package/dist/lib/utilities/write-file.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +15 -2
- package/dist/plugin-utils/index.d.cts +2 -2
- package/dist/plugin-utils/index.d.mts +2 -2
- package/dist/plugin-utils/index.mjs +3 -3
- package/dist/plugin-utils/logging.cjs +325 -4
- package/dist/plugin-utils/logging.d.cts +77 -3
- package/dist/plugin-utils/logging.d.cts.map +1 -1
- package/dist/plugin-utils/logging.d.mts +77 -3
- package/dist/plugin-utils/logging.d.mts.map +1 -1
- package/dist/plugin-utils/logging.mjs +311 -4
- package/dist/plugin-utils/logging.mjs.map +1 -1
- package/dist/types/config.d.cts +11 -4
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +11 -4
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/context.d.cts +17 -28
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +17 -28
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +3 -0
- package/dist/types/logging.cjs +48 -0
- package/dist/types/logging.d.cts +174 -0
- package/dist/types/logging.d.cts.map +1 -0
- package/dist/types/logging.d.mts +174 -0
- package/dist/types/logging.d.mts.map +1 -0
- package/dist/types/logging.mjs +45 -0
- package/dist/types/logging.mjs.map +1 -0
- package/package.json +74 -442
- package/dist/lib/logger.cjs +0 -106
- package/dist/lib/logger.d.cts +0 -42
- package/dist/lib/logger.d.cts.map +0 -1
- package/dist/lib/logger.d.mts +0 -42
- package/dist/lib/logger.d.mts.map +0 -1
- package/dist/lib/logger.mjs +0 -100
- package/dist/lib/logger.mjs.map +0 -1
- package/dist/types/log.cjs +0 -26
- package/dist/types/log.d.cts +0 -90
- package/dist/types/log.d.cts.map +0 -1
- package/dist/types/log.d.mts +0 -90
- package/dist/types/log.d.mts.map +0 -1
- package/dist/types/log.mjs +0 -25
- package/dist/types/log.mjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { LogLevelResolvedConfig, LogLevelUserConfig } from "../types/
|
|
1
|
+
import { CustomLogger, LogCategory, LogFn, LogFnOptions, LogLevel, LogLevelResolvedConfig, LogLevelUserConfig, LogMeta, Logger, LoggerMessage, LoggerOptions } from "../types/logging.mjs";
|
|
2
2
|
import { UnresolvedContext } from "../types/context.mjs";
|
|
3
3
|
import { Mode } from "../types/config.mjs";
|
|
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
|
|
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.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.mts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":"
|
|
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"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { LOG_LEVELS, LogCategories, LogLevels } from "../types/logging.mjs";
|
|
2
|
+
import { DEFAULT_ENVIRONMENT } from "../constants/environments.mjs";
|
|
1
3
|
import { DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL } from "../constants/log-level.mjs";
|
|
2
4
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
3
5
|
import { defu as defu$1 } from "defu";
|
|
4
6
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
5
7
|
import { isString } from "@stryke/type-checks/is-string";
|
|
8
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
9
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
10
|
+
import { getLogFn, getLogLevel } from "@storm-software/config-tools/logger";
|
|
11
|
+
import { getColor } from "@storm-software/config-tools/utilities/colors";
|
|
12
|
+
import { uuid } from "@stryke/unique-id/uuid";
|
|
13
|
+
import chalk from "chalk";
|
|
6
14
|
|
|
7
15
|
//#region src/plugin-utils/logging.ts
|
|
8
16
|
/**
|
|
@@ -32,7 +40,8 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
32
40
|
hooks: "trace",
|
|
33
41
|
env: "trace",
|
|
34
42
|
ipc: "trace",
|
|
35
|
-
config: "trace"
|
|
43
|
+
config: "trace",
|
|
44
|
+
babel: "trace"
|
|
36
45
|
};
|
|
37
46
|
else if (logLevel === "silent") return {
|
|
38
47
|
general: "silent",
|
|
@@ -43,7 +52,8 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
43
52
|
hooks: "silent",
|
|
44
53
|
env: "silent",
|
|
45
54
|
ipc: "silent",
|
|
46
|
-
config: "silent"
|
|
55
|
+
config: "silent",
|
|
56
|
+
babel: "silent"
|
|
47
57
|
};
|
|
48
58
|
let defaultLogLevel;
|
|
49
59
|
if (mode === "development") defaultLogLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
|
|
@@ -58,12 +68,309 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
58
68
|
hooks: logLevel,
|
|
59
69
|
env: defaultLogLevel.env,
|
|
60
70
|
ipc: defaultLogLevel.ipc,
|
|
61
|
-
config: defaultLogLevel.config
|
|
71
|
+
config: defaultLogLevel.config,
|
|
72
|
+
babel: logLevel
|
|
62
73
|
};
|
|
63
74
|
else if (isSetObject(logLevel)) return defu$1(logLevel, defaultLogLevel);
|
|
64
75
|
return defaultLogLevel;
|
|
65
76
|
}
|
|
77
|
+
const BADGE_COLORS = [
|
|
78
|
+
"#00A0DD",
|
|
79
|
+
"#6FCE4E",
|
|
80
|
+
"#FBBF24",
|
|
81
|
+
"#F43F5E",
|
|
82
|
+
"#3B82F6",
|
|
83
|
+
"#A855F7",
|
|
84
|
+
"#469592",
|
|
85
|
+
"#288EDF",
|
|
86
|
+
"#D8B4FE",
|
|
87
|
+
"#10B981",
|
|
88
|
+
"#EF4444",
|
|
89
|
+
"#F0EC56",
|
|
90
|
+
"#F472B6",
|
|
91
|
+
"#22D3EE",
|
|
92
|
+
"#EAB308",
|
|
93
|
+
"#84CC16",
|
|
94
|
+
"#F87171",
|
|
95
|
+
"#0EA5E9",
|
|
96
|
+
"#D946EF",
|
|
97
|
+
"#FACC15",
|
|
98
|
+
"#34D399",
|
|
99
|
+
"#8B5CF6"
|
|
100
|
+
];
|
|
101
|
+
const BRAND_COLOR = getColor("brand");
|
|
102
|
+
/**
|
|
103
|
+
* Generate a consistent color based on the input text.
|
|
104
|
+
*
|
|
105
|
+
* @param text - The input text to generate the color from.
|
|
106
|
+
* @return A hexadecimal color string.
|
|
107
|
+
*/
|
|
108
|
+
const getTextColor = (text) => {
|
|
109
|
+
return BADGE_COLORS[text.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Generate a consistent color based on the input text.
|
|
113
|
+
*
|
|
114
|
+
* @param text - The input text to generate the color from.
|
|
115
|
+
* @return A hexadecimal color string.
|
|
116
|
+
*/
|
|
117
|
+
const colorText = (text) => {
|
|
118
|
+
const title = titleCase(text);
|
|
119
|
+
return chalk.hex(getTextColor(title))(title);
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Generate a consistent color based on the input text.
|
|
123
|
+
*
|
|
124
|
+
* @param text - The input text to generate the color from.
|
|
125
|
+
* @return A hexadecimal color string.
|
|
126
|
+
*/
|
|
127
|
+
const colorBackground = (text) => {
|
|
128
|
+
const title = titleCase(text);
|
|
129
|
+
return chalk.inverse.hex(getTextColor(title))(` ${title} `);
|
|
130
|
+
};
|
|
131
|
+
const consoleLog = (meta, ...args) => getLogFn(getLogLevel(meta.type), { logLevel: "trace" })(`${meta.name ? chalk.bold.hex(BRAND_COLOR)(kebabCase(meta.name)) : ""}${meta.command ? chalk.hex(BRAND_COLOR)(` (${meta.command})`) : ""}${meta.name ? chalk.grey(" > ") : ""}${(meta.source || meta.plugin) && (!meta.name || kebabCase(meta.source || meta.plugin) !== kebabCase(meta.name)) ? `${chalk.bold.hex(BRAND_COLOR)(kebabCase(meta.source || meta.plugin))}${chalk.grey(" > ")}` : ""}${meta.environment && kebabCase(meta.environment) !== "default" ? `${chalk.bold.hex(BRAND_COLOR)(kebabCase(meta.environment))}${chalk.grey(" > ")}` : ""}${meta.category && meta.category !== LogCategories.GENERAL ? ` ${colorBackground(kebabCase(meta.category))} ` : ""}${args.join(" ")} `.trim());
|
|
132
|
+
function isValidLogLevel(logLevel, type) {
|
|
133
|
+
if (logLevel === LogLevels.SILENT) return false;
|
|
134
|
+
return LOG_LEVELS.indexOf(logLevel) >= LOG_LEVELS.indexOf(type);
|
|
135
|
+
}
|
|
136
|
+
function isValidLogLevelConfig(type, logLevel, category = LogCategories.GENERAL) {
|
|
137
|
+
return isValidLogLevel(logLevel[category], type);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Create a logging function with a specific name and options.
|
|
141
|
+
*
|
|
142
|
+
* @param name - The name of the logging function.
|
|
143
|
+
* @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.
|
|
144
|
+
* @returns A logging function.
|
|
145
|
+
*/
|
|
146
|
+
const createLogFn = (name, options) => {
|
|
147
|
+
const logLevel = resolveLogLevel(options.logLevel, options.mode);
|
|
148
|
+
return (meta, ...args) => {
|
|
149
|
+
const logMeta = isSetObject(meta) ? {
|
|
150
|
+
logId: uuid(),
|
|
151
|
+
timestamp: Date.now(),
|
|
152
|
+
category: LogCategories.GENERAL,
|
|
153
|
+
...options,
|
|
154
|
+
...meta,
|
|
155
|
+
name
|
|
156
|
+
} : {
|
|
157
|
+
logId: uuid(),
|
|
158
|
+
timestamp: Date.now(),
|
|
159
|
+
category: LogCategories.GENERAL,
|
|
160
|
+
...options,
|
|
161
|
+
type: meta,
|
|
162
|
+
name
|
|
163
|
+
};
|
|
164
|
+
if (isValidLogLevelConfig(logMeta.type, logLevel, logMeta.category ? logMeta.category : LogCategories.GENERAL)) consoleLog(logMeta, ...args);
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
const validateLogger = (type, name, options, callback) => {
|
|
168
|
+
const logLevel = resolveLogLevel(options.logLevel, options.mode);
|
|
169
|
+
return (message) => {
|
|
170
|
+
const params = isSetString(message) ? {
|
|
171
|
+
name,
|
|
172
|
+
plugin: options.plugin,
|
|
173
|
+
meta: {
|
|
174
|
+
type,
|
|
175
|
+
name,
|
|
176
|
+
category: LogCategories.GENERAL,
|
|
177
|
+
logId: uuid(),
|
|
178
|
+
timestamp: Date.now(),
|
|
179
|
+
...options
|
|
180
|
+
},
|
|
181
|
+
message
|
|
182
|
+
} : {
|
|
183
|
+
name,
|
|
184
|
+
plugin: options.plugin,
|
|
185
|
+
...message,
|
|
186
|
+
meta: {
|
|
187
|
+
type,
|
|
188
|
+
name,
|
|
189
|
+
category: LogCategories.GENERAL,
|
|
190
|
+
logId: uuid(),
|
|
191
|
+
timestamp: Date.now(),
|
|
192
|
+
plugin: message.plugin,
|
|
193
|
+
...options,
|
|
194
|
+
...message.meta
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
if (isValidLogLevelConfig(type, logLevel, params.meta.category)) callback(params);
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
const validateCustomLogger = (type, name, options, callback, customCallback) => {
|
|
201
|
+
const logLevel = resolveLogLevel(options.logLevel, options.mode);
|
|
202
|
+
return (message) => {
|
|
203
|
+
const params = isSetString(message) ? {
|
|
204
|
+
name,
|
|
205
|
+
plugin: options.plugin,
|
|
206
|
+
meta: {
|
|
207
|
+
type,
|
|
208
|
+
name,
|
|
209
|
+
category: LogCategories.GENERAL,
|
|
210
|
+
logId: uuid(),
|
|
211
|
+
timestamp: Date.now(),
|
|
212
|
+
...options
|
|
213
|
+
},
|
|
214
|
+
message
|
|
215
|
+
} : {
|
|
216
|
+
name,
|
|
217
|
+
plugin: options.plugin,
|
|
218
|
+
...message,
|
|
219
|
+
meta: {
|
|
220
|
+
type,
|
|
221
|
+
name,
|
|
222
|
+
category: LogCategories.GENERAL,
|
|
223
|
+
logId: uuid(),
|
|
224
|
+
timestamp: Date.now(),
|
|
225
|
+
plugin: message.plugin,
|
|
226
|
+
...options,
|
|
227
|
+
...message.meta
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
if (isValidLogLevelConfig(type, logLevel, params.meta.category)) {
|
|
231
|
+
callback?.(params);
|
|
232
|
+
customCallback?.(params);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Create a logging function with a specific name and options.
|
|
238
|
+
*
|
|
239
|
+
* @param logger - The original logger to wrap with the custom logger.
|
|
240
|
+
* @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
|
|
241
|
+
* @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.
|
|
242
|
+
*/
|
|
243
|
+
const withLogger = (logger, secondaryLogger) => {
|
|
244
|
+
const options = {
|
|
245
|
+
...secondaryLogger.options,
|
|
246
|
+
...logger.options
|
|
247
|
+
};
|
|
248
|
+
return {
|
|
249
|
+
options,
|
|
250
|
+
error: validateLogger("error", options.name, options, (message) => {
|
|
251
|
+
logger.error?.(message);
|
|
252
|
+
secondaryLogger.error?.(message);
|
|
253
|
+
}),
|
|
254
|
+
warn: validateLogger("warn", options.name, options, (message) => {
|
|
255
|
+
logger.warn?.(message);
|
|
256
|
+
secondaryLogger.warn?.(message);
|
|
257
|
+
}),
|
|
258
|
+
info: validateLogger("info", options.name, options, (message) => {
|
|
259
|
+
logger.info?.(message);
|
|
260
|
+
secondaryLogger.info?.(message);
|
|
261
|
+
}),
|
|
262
|
+
debug: validateLogger("debug", options.name, options, (message) => {
|
|
263
|
+
logger.debug?.(message);
|
|
264
|
+
secondaryLogger.debug?.(message);
|
|
265
|
+
}),
|
|
266
|
+
trace: validateLogger("trace", options.name, options, (message) => {
|
|
267
|
+
logger.trace?.(message);
|
|
268
|
+
secondaryLogger.trace?.(message);
|
|
269
|
+
})
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Create a logging function with a specific name and options.
|
|
274
|
+
*
|
|
275
|
+
* @param logger - The original logger to wrap with the custom logger.
|
|
276
|
+
* @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
|
|
277
|
+
* @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.
|
|
278
|
+
*/
|
|
279
|
+
const withCustomLogger = (logger, customLogger) => {
|
|
280
|
+
return {
|
|
281
|
+
options: logger.options,
|
|
282
|
+
error: validateCustomLogger("error", logger.options.name, logger.options, logger.error.bind(logger), customLogger.error?.bind(customLogger)),
|
|
283
|
+
warn: validateCustomLogger("warn", logger.options.name, logger.options, logger.warn.bind(logger), customLogger.warn?.bind(customLogger)),
|
|
284
|
+
info: validateCustomLogger("info", logger.options.name, logger.options, logger.info.bind(logger), customLogger.info?.bind(customLogger)),
|
|
285
|
+
debug: validateCustomLogger("debug", logger.options.name, logger.options, logger.debug.bind(logger), customLogger.debug?.bind(customLogger)),
|
|
286
|
+
trace: validateCustomLogger("trace", logger.options.name, logger.options, logger.trace.bind(logger), customLogger.trace?.bind(customLogger))
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
const consoleLogger = (type, message) => consoleLog(isSetString(message) ? {
|
|
290
|
+
type,
|
|
291
|
+
category: LogCategories.GENERAL,
|
|
292
|
+
logId: uuid(),
|
|
293
|
+
timestamp: Date.now()
|
|
294
|
+
} : {
|
|
295
|
+
type,
|
|
296
|
+
category: LogCategories.GENERAL,
|
|
297
|
+
logId: uuid(),
|
|
298
|
+
timestamp: Date.now(),
|
|
299
|
+
...message
|
|
300
|
+
}, isSetString(message) ? message : message.message);
|
|
301
|
+
/**
|
|
302
|
+
* Create a logging function with a specific name and options.
|
|
303
|
+
*
|
|
304
|
+
* @param name - The name of the logging function.
|
|
305
|
+
* @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.
|
|
306
|
+
* @returns A logging function.
|
|
307
|
+
*/
|
|
308
|
+
const createLogger = (name, options, callback = consoleLogger) => {
|
|
309
|
+
return {
|
|
310
|
+
options: {
|
|
311
|
+
...options,
|
|
312
|
+
name
|
|
313
|
+
},
|
|
314
|
+
error: validateLogger("error", name, {
|
|
315
|
+
...options,
|
|
316
|
+
name
|
|
317
|
+
}, (message) => callback("error", message)),
|
|
318
|
+
warn: validateLogger("warn", name, {
|
|
319
|
+
...options,
|
|
320
|
+
name
|
|
321
|
+
}, (message) => callback("warn", message)),
|
|
322
|
+
info: validateLogger("info", name, {
|
|
323
|
+
...options,
|
|
324
|
+
name
|
|
325
|
+
}, (message) => callback("info", message)),
|
|
326
|
+
debug: validateLogger("debug", name, {
|
|
327
|
+
...options,
|
|
328
|
+
name
|
|
329
|
+
}, (message) => callback("debug", message)),
|
|
330
|
+
trace: validateLogger("trace", name, {
|
|
331
|
+
...options,
|
|
332
|
+
name
|
|
333
|
+
}, (message) => callback("trace", message))
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* Extend a logging function with a specific name, adding a colored badge to the log output.
|
|
338
|
+
*
|
|
339
|
+
* @param logFn - The original logging function to extend.
|
|
340
|
+
* @param options - The overlay metadata to use for the badge in the log output.
|
|
341
|
+
* @returns A new logging function that includes the badge in its output.
|
|
342
|
+
*/
|
|
343
|
+
const extendLogFn = (logFn, options) => {
|
|
344
|
+
return (meta, ...args) => options.source || options.category ? logFn(isSetObject(meta) ? {
|
|
345
|
+
...options,
|
|
346
|
+
...meta
|
|
347
|
+
} : {
|
|
348
|
+
...options,
|
|
349
|
+
type: meta
|
|
350
|
+
}, `${colorBackground(String(options.source || options.category))} ${args.filter(Boolean).map((arg) => String(arg).trim()).join(" ")} `) : logFn(meta, ...args);
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* 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.
|
|
354
|
+
*
|
|
355
|
+
* @param logger - The original logger to extend.
|
|
356
|
+
* @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.
|
|
357
|
+
* @returns A new logger that includes the badge in its output for each log message.
|
|
358
|
+
*/
|
|
359
|
+
const extendLogger = (logger, options) => {
|
|
360
|
+
const opts = {
|
|
361
|
+
...logger.options,
|
|
362
|
+
...options
|
|
363
|
+
};
|
|
364
|
+
return {
|
|
365
|
+
options: opts,
|
|
366
|
+
error: validateLogger("error", opts.name, opts, logger.error.bind(logger)),
|
|
367
|
+
warn: validateLogger("warn", opts.name, opts, logger.warn.bind(logger)),
|
|
368
|
+
info: validateLogger("info", opts.name, opts, logger.info.bind(logger)),
|
|
369
|
+
debug: validateLogger("debug", opts.name, opts, logger.debug.bind(logger)),
|
|
370
|
+
trace: validateLogger("trace", opts.name, opts, logger.trace.bind(logger))
|
|
371
|
+
};
|
|
372
|
+
};
|
|
66
373
|
|
|
67
374
|
//#endregion
|
|
68
|
-
export { isVerbose, resolveLogLevel };
|
|
375
|
+
export { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger };
|
|
69
376
|
//# sourceMappingURL=logging.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.mjs","names":["defu"],"sources":["../../src/plugin-utils/logging.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { defu } from \"defu\";\nimport {\n DEFAULT_DEVELOPMENT_LOG_LEVEL,\n DEFAULT_PRODUCTION_LOG_LEVEL,\n DEFAULT_TEST_LOG_LEVEL\n} from \"../constants/log-level\";\nimport { Mode, UnresolvedContext } from \"../types\";\nimport { LogLevelResolvedConfig, LogLevelUserConfig } from \"../types/log\";\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevel - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(logLevel: string): boolean;\n\n/**\n * Determines if the provided context is considered verbose (debug or trace).\n *\n * @param context - The context to check, which contains the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(context: UnresolvedContext): boolean;\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevelOrContext - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(\n logLevelOrContext: string | UnresolvedContext\n): boolean {\n const level = isString(logLevelOrContext)\n ? logLevelOrContext\n : logLevelOrContext.config.logLevel;\n\n return level === \"debug\" || level === \"trace\";\n}\n\n/**\n * 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.\n *\n * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.\n * @param mode - The current mode of the application (e.g., \"development\", \"test\", \"production\"), which determines the default log levels.\n * @returns A LogLevelResolvedConfig object specifying the log level for each log category.\n */\nexport function resolveLogLevel(\n logLevel: LogLevelUserConfig,\n mode?: Mode\n): LogLevelResolvedConfig {\n if (logLevel === \"trace\") {\n return {\n general: \"trace\",\n fs: \"trace\",\n performance: \"trace\",\n network: \"trace\",\n plugins: \"trace\",\n hooks: \"trace\",\n env: \"trace\",\n ipc: \"trace\",\n config: \"trace\"\n };\n } else if (logLevel === \"silent\") {\n return {\n general: \"silent\",\n fs: \"silent\",\n performance: \"silent\",\n network: \"silent\",\n plugins: \"silent\",\n hooks: \"silent\",\n env: \"silent\",\n ipc: \"silent\",\n config: \"silent\"\n };\n }\n\n let defaultLogLevel: LogLevelResolvedConfig;\n if (mode === \"development\") {\n defaultLogLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;\n } else if (mode === \"test\") {\n defaultLogLevel = DEFAULT_TEST_LOG_LEVEL;\n } else {\n defaultLogLevel = DEFAULT_PRODUCTION_LOG_LEVEL;\n }\n\n if (isSetString(logLevel)) {\n return {\n general: logLevel,\n fs: defaultLogLevel.fs,\n performance: logLevel,\n network: defaultLogLevel.network,\n plugins: logLevel,\n hooks: logLevel,\n env: defaultLogLevel.env,\n ipc: defaultLogLevel.ipc,\n config: defaultLogLevel.config\n };\n } else if (isSetObject(logLevel)) {\n return defu(logLevel, defaultLogLevel) as LogLevelResolvedConfig;\n }\n\n return defaultLogLevel;\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,SAAgB,UACd,mBACS;CACT,MAAM,QAAQ,SAAS,kBAAkB,GACrC,oBACA,kBAAkB,OAAO;AAE7B,QAAO,UAAU,WAAW,UAAU;;;;;;;;;AAUxC,SAAgB,gBACd,UACA,MACwB;AACxB,KAAI,aAAa,QACf,QAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,SAAS;EACT,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACT;UACQ,aAAa,SACtB,QAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,SAAS;EACT,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACT;CAGH,IAAI;AACJ,KAAI,SAAS,cACX,mBAAkB;UACT,SAAS,OAClB,mBAAkB;KAElB,mBAAkB;AAGpB,KAAI,YAAY,SAAS,CACvB,QAAO;EACL,SAAS;EACT,IAAI,gBAAgB;EACpB,aAAa;EACb,SAAS,gBAAgB;EACzB,SAAS;EACT,OAAO;EACP,KAAK,gBAAgB;EACrB,KAAK,gBAAgB;EACrB,QAAQ,gBAAgB;EACzB;UACQ,YAAY,SAAS,CAC9B,QAAOA,OAAK,UAAU,gBAAgB;AAGxC,QAAO"}
|
|
1
|
+
{"version":3,"file":"logging.mjs","names":["defu"],"sources":["../../src/plugin-utils/logging.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { RequiredKeys } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport chalk from \"chalk\";\nimport { defu } from \"defu\";\nimport { DEFAULT_ENVIRONMENT } from \"../constants/environments\";\nimport {\n DEFAULT_DEVELOPMENT_LOG_LEVEL,\n DEFAULT_PRODUCTION_LOG_LEVEL,\n DEFAULT_TEST_LOG_LEVEL\n} from \"../constants/log-level\";\nimport { Mode } from \"../types/config\";\nimport { UnresolvedContext } from \"../types/context\";\nimport type {\n CustomLogger,\n CustomLoggerMessage,\n LogCategory,\n LogFn,\n LogFnMeta,\n LogFnOptions,\n LoggerMessage,\n LoggerOptions,\n LogLevel,\n LogLevelResolvedConfig,\n LogLevelUserConfig,\n LogMeta\n} from \"../types/logging\";\nimport { LOG_LEVELS, LogCategories, Logger, LogLevels } from \"../types/logging\";\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevel - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(logLevel: string): boolean;\n\n/**\n * Determines if the provided context is considered verbose (debug or trace).\n *\n * @param context - The context to check, which contains the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(context: UnresolvedContext): boolean;\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevelOrContext - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(\n logLevelOrContext: string | UnresolvedContext\n): boolean {\n const level = isString(logLevelOrContext)\n ? logLevelOrContext\n : logLevelOrContext.config.logLevel;\n\n return level === \"debug\" || level === \"trace\";\n}\n\n/**\n * 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.\n *\n * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.\n * @param mode - The current mode of the application (e.g., \"development\", \"test\", \"production\"), which determines the default log levels.\n * @returns A LogLevelResolvedConfig object specifying the log level for each log category.\n */\nexport function resolveLogLevel(\n logLevel?: LogLevelUserConfig,\n mode?: Mode\n): LogLevelResolvedConfig {\n if (logLevel === \"trace\") {\n return {\n general: \"trace\",\n fs: \"trace\",\n performance: \"trace\",\n network: \"trace\",\n plugins: \"trace\",\n hooks: \"trace\",\n env: \"trace\",\n ipc: \"trace\",\n config: \"trace\",\n babel: \"trace\"\n };\n } else if (logLevel === \"silent\") {\n return {\n general: \"silent\",\n fs: \"silent\",\n performance: \"silent\",\n network: \"silent\",\n plugins: \"silent\",\n hooks: \"silent\",\n env: \"silent\",\n ipc: \"silent\",\n config: \"silent\",\n babel: \"silent\"\n };\n }\n\n let defaultLogLevel: LogLevelResolvedConfig;\n if (mode === \"development\") {\n defaultLogLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;\n } else if (mode === \"test\") {\n defaultLogLevel = DEFAULT_TEST_LOG_LEVEL;\n } else {\n defaultLogLevel = DEFAULT_PRODUCTION_LOG_LEVEL;\n }\n\n if (isSetString(logLevel)) {\n return {\n general: logLevel,\n fs: defaultLogLevel.fs,\n performance: logLevel,\n network: defaultLogLevel.network,\n plugins: logLevel,\n hooks: logLevel,\n env: defaultLogLevel.env,\n ipc: defaultLogLevel.ipc,\n config: defaultLogLevel.config,\n babel: logLevel\n };\n } else if (isSetObject(logLevel)) {\n return defu(logLevel, defaultLogLevel) as LogLevelResolvedConfig;\n }\n\n return defaultLogLevel;\n}\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#D8B4FE\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\",\n \"#8B5CF6\"\n] as const;\n\nconst BRAND_COLOR = getColor(\"brand\");\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const getTextColor = (text: string): string => {\n return (\n BADGE_COLORS[\n text\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n );\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorText = (text: string): string => {\n const title = titleCase(text);\n\n return chalk.hex(getTextColor(title))(title);\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorBackground = (text: string): string => {\n const title = titleCase(text);\n\n return chalk.inverse.hex(getTextColor(title))(` ${title} `);\n};\n\nexport const consoleLog = (meta: LogMeta, ...args: string[]) =>\n getLogFn(getLogLevel(meta.type), {\n logLevel: \"trace\"\n })(\n `${meta.name ? chalk.bold.hex(BRAND_COLOR)(kebabCase(meta.name)) : \"\"}${\n meta.command ? chalk.hex(BRAND_COLOR)(` (${meta.command})`) : \"\"\n }${meta.name ? chalk.grey(\" > \") : \"\"}${\n (meta.source || meta.plugin) &&\n (!meta.name ||\n kebabCase(meta.source || meta.plugin) !== kebabCase(meta.name))\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.source || meta.plugin)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.environment && kebabCase(meta.environment) !== DEFAULT_ENVIRONMENT\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.environment)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.category && meta.category !== LogCategories.GENERAL\n ? ` ${colorBackground(kebabCase(meta.category))} `\n : \"\"\n }${args.join(\" \")} `.trim()\n );\n\nexport function isValidLogLevel(logLevel: LogLevel, type: LogLevel): boolean {\n if (logLevel === LogLevels.SILENT) {\n return false;\n }\n\n return LOG_LEVELS.indexOf(logLevel) >= LOG_LEVELS.indexOf(type);\n}\n\nexport function isValidLogLevelConfig(\n type: LogLevel,\n logLevel: LogLevelResolvedConfig,\n category: LogCategory = LogCategories.GENERAL\n): boolean {\n return isValidLogLevel(logLevel[category], type);\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @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.\n * @returns A logging function.\n */\nexport const createLogFn = (name: string, options: LogFnOptions): LogFn => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (meta: LogFnMeta | LogLevel, ...args: string[]) => {\n const logMeta = isSetObject(meta)\n ? {\n logId: uuid(),\n timestamp: Date.now(),\n category: LogCategories.GENERAL,\n ...options,\n ...meta,\n name\n }\n : {\n logId: uuid(),\n timestamp: Date.now(),\n category: LogCategories.GENERAL,\n ...options,\n type: meta,\n name\n };\n\n if (\n isValidLogLevelConfig(\n logMeta.type,\n logLevel,\n logMeta.category ? logMeta.category : LogCategories.GENERAL\n )\n ) {\n consoleLog(logMeta, ...args);\n }\n };\n};\n\nconst validateLogger = (\n type: LogLevel,\n name: string,\n options: LoggerOptions,\n callback: (message: string | LoggerMessage) => void\n) => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (message: string | LoggerMessage) => {\n const params = isSetString(message)\n ? {\n name,\n plugin: options.plugin,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...options\n },\n message\n }\n : {\n name,\n plugin: options.plugin,\n ...message,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n plugin: message.plugin,\n ...options,\n ...message.meta\n }\n };\n\n if (isValidLogLevelConfig(type, logLevel, params.meta.category)) {\n callback(params);\n }\n };\n};\n\nconst validateCustomLogger = (\n type: LogLevel,\n name: string,\n options: LoggerOptions,\n callback?: (message: string | LoggerMessage) => void,\n customCallback?: (message: CustomLoggerMessage) => void\n) => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (message: string | LoggerMessage) => {\n const params = isSetString(message)\n ? {\n name,\n plugin: options.plugin,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...options\n },\n message\n }\n : {\n name,\n plugin: options.plugin,\n ...message,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n plugin: message.plugin,\n ...options,\n ...message.meta\n }\n };\n\n if (isValidLogLevelConfig(type, logLevel, params.meta.category)) {\n callback?.(params);\n customCallback?.(params);\n }\n };\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @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.\n */\nexport const withLogger = (logger: Logger, secondaryLogger: Logger): Logger => {\n const options = { ...secondaryLogger.options, ...logger.options };\n\n return {\n options,\n error: validateLogger(\n \"error\",\n options.name!,\n options,\n (message: string | LoggerMessage) => {\n logger.error?.(message);\n secondaryLogger.error?.(message);\n }\n ),\n warn: validateLogger(\n \"warn\",\n options.name!,\n options,\n (message: string | LoggerMessage) => {\n logger.warn?.(message);\n secondaryLogger.warn?.(message);\n }\n ),\n info: validateLogger(\n \"info\",\n options.name!,\n options,\n (message: string | LoggerMessage) => {\n logger.info?.(message);\n secondaryLogger.info?.(message);\n }\n ),\n debug: validateLogger(\n \"debug\",\n options.name!,\n options,\n (message: string | LoggerMessage) => {\n logger.debug?.(message);\n secondaryLogger.debug?.(message);\n }\n ),\n trace: validateLogger(\n \"trace\",\n options.name!,\n options,\n (message: string | LoggerMessage) => {\n logger.trace?.(message);\n secondaryLogger.trace?.(message);\n }\n )\n };\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @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.\n */\nexport const withCustomLogger = (\n logger: Logger,\n customLogger: CustomLogger\n): Logger => {\n return {\n options: logger.options,\n error: validateCustomLogger(\n \"error\",\n logger.options.name!,\n logger.options,\n logger.error.bind(logger),\n customLogger.error?.bind(customLogger)\n ),\n warn: validateCustomLogger(\n \"warn\",\n logger.options.name!,\n logger.options,\n logger.warn.bind(logger),\n customLogger.warn?.bind(customLogger)\n ),\n info: validateCustomLogger(\n \"info\",\n logger.options.name!,\n logger.options,\n logger.info.bind(logger),\n customLogger.info?.bind(customLogger)\n ),\n debug: validateCustomLogger(\n \"debug\",\n logger.options.name!,\n logger.options,\n logger.debug.bind(logger),\n customLogger.debug?.bind(customLogger)\n ),\n trace: validateCustomLogger(\n \"trace\",\n logger.options.name!,\n logger.options,\n logger.trace.bind(logger),\n customLogger.trace?.bind(customLogger)\n )\n };\n};\n\nexport const consoleLogger = (\n type: LogLevel,\n message: string | LoggerMessage\n) =>\n consoleLog(\n isSetString(message)\n ? {\n type,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now()\n }\n : {\n type,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...message\n },\n isSetString(message) ? message : message.message\n );\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @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.\n * @returns A logging function.\n */\nexport const createLogger = (\n name: string,\n options: LoggerOptions,\n callback: (\n type: LogLevel,\n message: string | LoggerMessage\n ) => void = consoleLogger\n): Logger => {\n return {\n options: { ...options, name },\n error: validateLogger(\"error\", name, { ...options, name }, message =>\n callback(\"error\", message)\n ),\n warn: validateLogger(\"warn\", name, { ...options, name }, message =>\n callback(\"warn\", message)\n ),\n info: validateLogger(\"info\", name, { ...options, name }, message =>\n callback(\"info\", message)\n ),\n debug: validateLogger(\"debug\", name, { ...options, name }, message =>\n callback(\"debug\", message)\n ),\n trace: validateLogger(\"trace\", name, { ...options, name }, message =>\n callback(\"trace\", message)\n )\n };\n};\n\n/**\n * Extend a logging function with a specific name, adding a colored badge to the log output.\n *\n * @param logFn - The original logging function to extend.\n * @param options - The overlay metadata to use for the badge in the log output.\n * @returns A new logging function that includes the badge in its output.\n */\nexport const extendLogFn = (logFn: LogFn, options: LogFnOptions): LogFn => {\n return (meta, ...args) =>\n options.source || options.category\n ? logFn(\n isSetObject(meta)\n ? { ...options, ...meta }\n : { ...options, type: meta },\n `${colorBackground(String(options.source || options.category))} ${args\n .filter(Boolean)\n .map(arg => String(arg).trim())\n .join(\" \")} `\n )\n : logFn(meta, ...args);\n};\n\n/**\n * 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.\n *\n * @param logger - The original logger to extend.\n * @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.\n * @returns A new logger that includes the badge in its output for each log message.\n */\nexport const extendLogger = (\n logger: Logger,\n options: LoggerOptions\n): Logger => {\n const opts = { ...logger.options, ...options } as RequiredKeys<\n LoggerOptions,\n \"name\"\n >;\n\n return {\n options: opts,\n error: validateLogger(\"error\", opts.name, opts, logger.error.bind(logger)),\n warn: validateLogger(\"warn\", opts.name, opts, logger.warn.bind(logger)),\n info: validateLogger(\"info\", opts.name, opts, logger.info.bind(logger)),\n debug: validateLogger(\"debug\", opts.name, opts, logger.debug.bind(logger)),\n trace: validateLogger(\"trace\", opts.name, opts, logger.trace.bind(logger))\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgB,UACd,mBACS;CACT,MAAM,QAAQ,SAAS,kBAAkB,GACrC,oBACA,kBAAkB,OAAO;AAE7B,QAAO,UAAU,WAAW,UAAU;;;;;;;;;AAUxC,SAAgB,gBACd,UACA,MACwB;AACxB,KAAI,aAAa,QACf,QAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,SAAS;EACT,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACR,OAAO;EACR;UACQ,aAAa,SACtB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a,gBACX,QACA,YACW;CACX,MAAM,OAAO;EAAE,GAAG,OAAO;EAAS,GAAG;EAAS;AAK9C,QAAO;EACL,SAAS;EACT,OAAO,eAAe,SAAS,KAAK,MAAM,MAAM,OAAO,MAAM,KAAK,OAAO,CAAC;EAC1E,MAAM,eAAe,QAAQ,KAAK,MAAM,MAAM,OAAO,KAAK,KAAK,OAAO,CAAC;EACvE,MAAM,eAAe,QAAQ,KAAK,MAAM,MAAM,OAAO,KAAK,KAAK,OAAO,CAAC;EACvE,OAAO,eAAe,SAAS,KAAK,MAAM,MAAM,OAAO,MAAM,KAAK,OAAO,CAAC;EAC1E,OAAO,eAAe,SAAS,KAAK,MAAM,MAAM,OAAO,MAAM,KAAK,OAAO,CAAC;EAC3E"}
|
package/dist/types/config.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoragePort, StoragePreset } from "./fs.cjs";
|
|
2
2
|
import { Plugin } from "./plugin.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { CustomLogger, LogLevelResolvedConfig, LogLevelUserConfig } from "./logging.cjs";
|
|
4
4
|
import { TSConfig } from "./tsconfig.cjs";
|
|
5
5
|
import { PluginContext } from "./context.cjs";
|
|
6
6
|
import { Format } from "@storm-software/build-tools/types";
|
|
@@ -234,6 +234,10 @@ interface OutputConfig {
|
|
|
234
234
|
storage?: StoragePort | StoragePreset;
|
|
235
235
|
}
|
|
236
236
|
interface EngineOptions {
|
|
237
|
+
/**
|
|
238
|
+
* The name of the project
|
|
239
|
+
*/
|
|
240
|
+
name?: string;
|
|
237
241
|
/**
|
|
238
242
|
* The root directory of the project
|
|
239
243
|
*/
|
|
@@ -276,7 +280,7 @@ interface EngineOptions {
|
|
|
276
280
|
*/
|
|
277
281
|
configFile?: string;
|
|
278
282
|
}
|
|
279
|
-
type ResolvedEngineOptions = PartialKeys<Required<EngineOptions>, "organization" | "configFile">;
|
|
283
|
+
type ResolvedEngineOptions = PartialKeys<Required<EngineOptions>, "organization" | "configFile" | "name">;
|
|
280
284
|
interface ExecutionOptions extends EngineOptions {
|
|
281
285
|
/**
|
|
282
286
|
* A unique identifier for the current execution instance, which can be used for logging and other purposes to distinguish between different executions in the same process.
|
|
@@ -429,9 +433,12 @@ interface UserConfig extends Config, ExecutionOptions {
|
|
|
429
433
|
*/
|
|
430
434
|
logLevel?: LogLevelUserConfig;
|
|
431
435
|
/**
|
|
432
|
-
* A custom logger
|
|
436
|
+
* A custom logger instance that implements the {@link CustomLogger} interface, which can be used for logging messages during the build process instead of the default Powerlines logger.
|
|
437
|
+
*
|
|
438
|
+
* @remarks
|
|
439
|
+
* Providing a custom logger allows you to integrate Powerlines logging with your own logging system or to customize the logging behavior, such as formatting log messages differently or sending logs to an external service. If a custom logger is not provided, Powerlines will use its default logger implementation.
|
|
433
440
|
*/
|
|
434
|
-
customLogger?:
|
|
441
|
+
customLogger?: CustomLogger;
|
|
435
442
|
/**
|
|
436
443
|
* The type of project being built
|
|
437
444
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/types/config.ts"],"mappings":";;;;;;;;;;;;;;;;;AA+CA;KAAY,eAAA,GAAkB,OAAA,CAAQ,oBAAA,IACpC,QAAA,CAAS,IAAA,CAAK,oBAAA;AAAA,KAEJ,aAAA,yBACc,aAAA,GAAgB,aAAA,qBAErC,OAAA,EAAS,QAAA,KAAa,YAAA,CAAa,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,QAAA;;;;KAKtD,iBAAA,kBACO,aAAA,GAAgB,aAAA,8BAErB,aAAA,CAAc,QAAA,EAAU,QAAA,GAAW,QAAA,KAAa,MAAA,CAAO,QAAA;;;;KAKzD,kBAAA,kBACO,aAAA,GAAgB,aAAA;EAI7B,MAAA,WAAiB,aAAA,CAAc,QAAA,EAAU,QAAA;EACzC,OAAA,EAAS,QAAA;AAAA;EAGT,MAAA,EAAQ,MAAA,CAAO,QAAA;EACf,OAAA;AAAA;AA1BN;;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AAA,EAAQ,oBAAA;EA/HY;;;EAoIpB,OAAA,EAAS,qBAAA;EAlIT;;;;;;;;;;EA8IA,iBAAA,EAAmB,kBAAA;EArJjB;;;EA0JF,YAAA,EAAc,YAAA,CAAa,WAAA;EArJf;;;EA0JZ,UAAA,EAAY,WAAA;EAxJC;;;EA6Jb,YAAA,EAAc,OAAA,CAAQ,WAAA;EA5JG;AAE7B;;EA+JI,OAAA,EAAS,YAAA,CAAa,YAAA,CAAa,WAAA;EA/JU;;;;;;EAuK7C,QAAA,EAAU,sBAAA;AAAA;AAAA"}
|
package/dist/types/config.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoragePort, StoragePreset } from "./fs.mjs";
|
|
2
2
|
import { Plugin } from "./plugin.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { CustomLogger, LogLevelResolvedConfig, LogLevelUserConfig } from "./logging.mjs";
|
|
4
4
|
import { TSConfig } from "./tsconfig.mjs";
|
|
5
5
|
import { PluginContext } from "./context.mjs";
|
|
6
6
|
import { ConfigLayer, ResolvedConfig } from "c12";
|
|
@@ -234,6 +234,10 @@ interface OutputConfig {
|
|
|
234
234
|
storage?: StoragePort | StoragePreset;
|
|
235
235
|
}
|
|
236
236
|
interface EngineOptions {
|
|
237
|
+
/**
|
|
238
|
+
* The name of the project
|
|
239
|
+
*/
|
|
240
|
+
name?: string;
|
|
237
241
|
/**
|
|
238
242
|
* The root directory of the project
|
|
239
243
|
*/
|
|
@@ -276,7 +280,7 @@ interface EngineOptions {
|
|
|
276
280
|
*/
|
|
277
281
|
configFile?: string;
|
|
278
282
|
}
|
|
279
|
-
type ResolvedEngineOptions = PartialKeys<Required<EngineOptions>, "organization" | "configFile">;
|
|
283
|
+
type ResolvedEngineOptions = PartialKeys<Required<EngineOptions>, "organization" | "configFile" | "name">;
|
|
280
284
|
interface ExecutionOptions extends EngineOptions {
|
|
281
285
|
/**
|
|
282
286
|
* A unique identifier for the current execution instance, which can be used for logging and other purposes to distinguish between different executions in the same process.
|
|
@@ -429,9 +433,12 @@ interface UserConfig extends Config, ExecutionOptions {
|
|
|
429
433
|
*/
|
|
430
434
|
logLevel?: LogLevelUserConfig;
|
|
431
435
|
/**
|
|
432
|
-
* A custom logger
|
|
436
|
+
* A custom logger instance that implements the {@link CustomLogger} interface, which can be used for logging messages during the build process instead of the default Powerlines logger.
|
|
437
|
+
*
|
|
438
|
+
* @remarks
|
|
439
|
+
* Providing a custom logger allows you to integrate Powerlines logging with your own logging system or to customize the logging behavior, such as formatting log messages differently or sending logs to an external service. If a custom logger is not provided, Powerlines will use its default logger implementation.
|
|
433
440
|
*/
|
|
434
|
-
customLogger?:
|
|
441
|
+
customLogger?: CustomLogger;
|
|
435
442
|
/**
|
|
436
443
|
* The type of project being built
|
|
437
444
|
*
|