@powerlines/engine 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.
@@ -27,10 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  }) : target, mod));
28
28
 
29
29
  //#endregion
30
- let _powerlines_core_lib_logger = require("@powerlines/core/lib/logger");
31
30
  let _powerlines_core_lib_utilities_file_header = require("@powerlines/core/lib/utilities/file-header");
32
31
  let _powerlines_core_lib_utilities_format = require("@powerlines/core/lib/utilities/format");
33
32
  let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
33
+ let _powerlines_core_plugin_utils_logging = require("@powerlines/core/plugin-utils/logging");
34
34
  let _storm_software_config_tools_logger_console = require("@storm-software/config-tools/logger/console");
35
35
  let _stryke_convert_to_array = require("@stryke/convert/to-array");
36
36
  let _stryke_fs_copy_file = require("@stryke/fs/copy-file");
@@ -68,7 +68,6 @@ let _stryke_fs_json = require("@stryke/fs/json");
68
68
  let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
69
69
  let _stryke_path_join = require("@stryke/path/join");
70
70
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
71
- let _powerlines_core = require("@powerlines/core");
72
71
  let _powerlines_core_lib_entry = require("@powerlines/core/lib/entry");
73
72
  let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
74
73
  let _stryke_hash = require("@stryke/hash");
@@ -82,6 +81,7 @@ let flat_cache = require("flat-cache");
82
81
  let oxc_parser = require("oxc-parser");
83
82
  let undici = require("undici");
84
83
  require("@stryke/fs/remove-file");
84
+ let _powerlines_core = require("@powerlines/core");
85
85
  let _stryke_capnp = require("@stryke/capnp");
86
86
  _stryke_capnp = __toESM(_stryke_capnp, 1);
87
87
  let _stryke_fs_buffer = require("@stryke/fs/buffer");
@@ -199,6 +199,40 @@ async function writeMetaFile(context) {
199
199
  await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
200
200
  }
201
201
 
202
+ //#endregion
203
+ //#region src/_internal/ipc/send.ts
204
+ function sendWriteLogMessage(context, type, message) {
205
+ const meta = {
206
+ ...(0, _stryke_type_checks_is_set_object.isSetObject)(message) && (0, _stryke_type_checks_is_set_object.isSetObject)(message.meta) ? message.meta : {},
207
+ ...context.logger.options
208
+ };
209
+ process.send?.({
210
+ id: (0, _stryke_unique_id_uuid.uuid)(),
211
+ type: "write-log",
212
+ executionId: meta.executionId ?? context.config.executionId,
213
+ executionIndex: meta.executionIndex ?? context.config.executionIndex,
214
+ environment: meta.environment,
215
+ timestamp: Date.now(),
216
+ payload: {
217
+ meta: {
218
+ type,
219
+ category: meta.category ?? _powerlines_core.LogCategories.GENERAL,
220
+ logId: meta.logId ?? (0, _stryke_unique_id_uuid.uuid)(),
221
+ timestamp: meta.timestamp ?? Date.now(),
222
+ name: meta.name ?? context.config.name,
223
+ executionId: meta.executionId ?? context.config.executionId,
224
+ executionIndex: meta.executionIndex ?? context.config.executionIndex,
225
+ command: meta.command ?? context.config.command,
226
+ hook: meta.hook,
227
+ environment: meta.environment,
228
+ plugin: meta.plugin,
229
+ source: meta.source
230
+ },
231
+ message: (0, _stryke_type_checks_is_set_string.isSetString)(message) ? message : message.message
232
+ }
233
+ });
234
+ }
235
+
202
236
  //#endregion
203
237
  //#region schemas/fs.ts
204
238
  var FileMetadata_KeyValuePair = class extends _stryke_capnp.Struct {
@@ -1016,9 +1050,9 @@ var VirtualFileSystem = class VirtualFileSystem {
1016
1050
  */
1017
1051
  #context;
1018
1052
  /**
1019
- * The file system's logging function.
1053
+ * The file system's logger client utility.
1020
1054
  */
1021
- #log;
1055
+ #logger;
1022
1056
  /**
1023
1057
  * Normalizes a given module id by resolving it against the built-ins path.
1024
1058
  *
@@ -1232,7 +1266,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1232
1266
  }
1233
1267
  }));
1234
1268
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(FileSystem));
1235
- result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
1269
+ result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
1236
1270
  return result;
1237
1271
  }
1238
1272
  /**
@@ -1266,7 +1300,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1266
1300
  }
1267
1301
  });
1268
1302
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(FileSystem));
1269
- result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
1303
+ result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
1270
1304
  return result;
1271
1305
  }
1272
1306
  /**
@@ -1400,7 +1434,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1400
1434
  return ret;
1401
1435
  }, {});
1402
1436
  }
1403
- this.#log = context.extendLog({
1437
+ this.#logger = context.extendLogger({
1404
1438
  source: "VFS",
1405
1439
  category: "fs"
1406
1440
  });
@@ -1530,7 +1564,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1530
1564
  listSync(path) {
1531
1565
  let resolvedPath = path;
1532
1566
  if (resolvedPath.includes("*")) {
1533
- this.#log("warn", `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
1567
+ this.#logger.warn(`Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
1534
1568
  resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
1535
1569
  }
1536
1570
  return (0, _stryke_helpers_get_unique.getUnique)(this.#getStorages(resolvedPath, true).map((storage) => storage.adapter.listSync(storage.relativeBase ? storage.base ? (0, _stryke_path_append.appendPath)(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)).flat().filter(Boolean));
@@ -1544,7 +1578,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1544
1578
  async list(path) {
1545
1579
  let resolvedPath = path;
1546
1580
  if (resolvedPath.includes("*")) {
1547
- this.#log("warn", `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
1581
+ this.#logger.warn(`Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
1548
1582
  resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
1549
1583
  }
1550
1584
  return (0, _stryke_helpers_get_unique.getUnique)((await Promise.all(this.#getStorages(resolvedPath, true).map(async (storage) => storage.adapter.list(storage.relativeBase ? storage.base ? (0, _stryke_path_append.appendPath)(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)))).flat().filter(Boolean));
@@ -1556,7 +1590,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1556
1590
  */
1557
1591
  async remove(path) {
1558
1592
  const normalizedPath = this.#normalizePath(path);
1559
- this.#log("trace", `Removing file: ${normalizedPath}`);
1593
+ this.#logger.trace(`Removing file: ${normalizedPath}`);
1560
1594
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
1561
1595
  if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) await adapter.remove(relativeKey);
1562
1596
  else await adapter.clear(relativeKey);
@@ -1574,7 +1608,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1574
1608
  */
1575
1609
  removeSync(path) {
1576
1610
  const normalizedPath = this.#normalizePath(path);
1577
- this.#log("trace", `Removing file: ${normalizedPath}`);
1611
+ this.#logger.trace(`Removing file: ${normalizedPath}`);
1578
1612
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
1579
1613
  if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) adapter.removeSync(relativeKey);
1580
1614
  else adapter.clearSync(relativeKey);
@@ -1720,7 +1754,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1720
1754
  const filePath = await this.resolve(path, void 0, { isFile: true });
1721
1755
  if (!filePath || !this.existsSync(filePath)) return;
1722
1756
  const { adapter } = this.#getStorage(filePath);
1723
- this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
1757
+ this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
1724
1758
  return await adapter.get(filePath) ?? void 0;
1725
1759
  }
1726
1760
  /**
@@ -1733,7 +1767,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1733
1767
  const filePath = this.resolveSync(path, void 0, { isFile: true });
1734
1768
  if (!filePath || !this.existsSync(filePath)) return;
1735
1769
  const { adapter } = this.#getStorage(filePath);
1736
- this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
1770
+ this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
1737
1771
  return adapter.getSync(filePath) ?? void 0;
1738
1772
  }
1739
1773
  /**
@@ -1748,15 +1782,15 @@ var VirtualFileSystem = class VirtualFileSystem {
1748
1782
  const meta = options.meta ?? {};
1749
1783
  const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
1750
1784
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1751
- this.#log("trace", `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1785
+ this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1752
1786
  let code = data;
1753
1787
  try {
1754
1788
  if (!options.skipFormat) code = await (0, _powerlines_core_lib_utilities_format.format)(this.#context, resolvedPath, data);
1755
1789
  } catch (err) {
1756
- if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log("warn", `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1790
+ if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
1757
1791
  code = data;
1758
1792
  }
1759
- this.#log("trace", `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(code)).size)})`);
1793
+ this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(code)).size)})`);
1760
1794
  const id = this.#normalizeId(meta.id || resolvedPath);
1761
1795
  this.metadata[id] = {
1762
1796
  type: "normal",
@@ -1779,7 +1813,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1779
1813
  const meta = options.meta ?? {};
1780
1814
  const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
1781
1815
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1782
- this.#log("trace", `Writing ${resolvedPath} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1816
+ this.#logger.trace(`Writing ${resolvedPath} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1783
1817
  const id = this.#normalizeId(meta.id || resolvedPath);
1784
1818
  this.metadata[id] = {
1785
1819
  type: "normal",
@@ -1943,7 +1977,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1943
1977
  async dispose() {
1944
1978
  if (!this.#isDisposed) {
1945
1979
  this.#isDisposed = true;
1946
- this.#log("debug", "Disposing virtual file system...");
1980
+ this.#logger.debug("Disposing virtual file system...");
1947
1981
  await this.remove((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"));
1948
1982
  const message = new _stryke_capnp.Message();
1949
1983
  const fs = message.initRoot(FileSystem);
@@ -1978,7 +2012,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1978
2012
  await (0, _stryke_fs_buffer.writeFileBuffer)((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1979
2013
  if (!this.#context.config.skipCache) this.resolverCache.save(true);
1980
2014
  await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
1981
- this.#log("trace", "Virtual file system has been disposed.");
2015
+ this.#logger.trace("Virtual file system has been disposed.");
1982
2016
  }
1983
2017
  }
1984
2018
  /**
@@ -2180,6 +2214,15 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2180
2214
  */
2181
2215
  configFile;
2182
2216
  /**
2217
+ * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.
2218
+ */
2219
+ get logger() {
2220
+ return this.createLogger({
2221
+ ...this.configFile.config,
2222
+ ...this.options
2223
+ });
2224
+ }
2225
+ /**
2183
2226
  * A timestamp representing when the context was initialized
2184
2227
  */
2185
2228
  get timestamp() {
@@ -2189,12 +2232,6 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2189
2232
  return (0, _powerlines_core_plugin_utils.resolveLogLevel)(this.options.logLevel, this.options.mode);
2190
2233
  }
2191
2234
  /**
2192
- * The logger function
2193
- */
2194
- get log() {
2195
- return this.createLog();
2196
- }
2197
- /**
2198
2235
  * The environment paths for the project
2199
2236
  */
2200
2237
  get envPaths() {
@@ -2223,7 +2260,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2223
2260
  * @param message - The message to log.
2224
2261
  */
2225
2262
  fatal(message) {
2226
- this.log("error", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2263
+ this.logger.error((0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2227
2264
  }
2228
2265
  /**
2229
2266
  * A logging function for error messages
@@ -2231,7 +2268,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2231
2268
  * @param message - The message to log.
2232
2269
  */
2233
2270
  error(message) {
2234
- this.log("error", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2271
+ this.logger.error((0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2235
2272
  }
2236
2273
  /**
2237
2274
  * A logging function for warning messages
@@ -2239,7 +2276,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2239
2276
  * @param message - The message to log.
2240
2277
  */
2241
2278
  warn(message) {
2242
- this.log("warn", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2279
+ this.logger.warn((0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2243
2280
  }
2244
2281
  /**
2245
2282
  * A logging function for informational messages
@@ -2247,7 +2284,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2247
2284
  * @param message - The message to log.
2248
2285
  */
2249
2286
  info(message) {
2250
- this.log("info", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2287
+ this.logger.info((0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2251
2288
  }
2252
2289
  /**
2253
2290
  * A logging function for debug messages
@@ -2255,7 +2292,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2255
2292
  * @param message - The message to log.
2256
2293
  */
2257
2294
  debug(message) {
2258
- this.log("debug", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2295
+ this.logger.debug((0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2259
2296
  }
2260
2297
  /**
2261
2298
  * A logging function for trace messages
@@ -2263,7 +2300,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2263
2300
  * @param message - The message to log.
2264
2301
  */
2265
2302
  trace(message) {
2266
- this.log("trace", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2303
+ this.logger.trace((0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2267
2304
  }
2268
2305
  /**
2269
2306
  * A function to create a timer for measuring the duration of asynchronous operations
@@ -2283,38 +2320,31 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2283
2320
  const startDuration = performance.now();
2284
2321
  return () => {
2285
2322
  const duration = performance.now() - startDuration;
2286
- this.log({
2287
- level: "info",
2288
- category: "performance"
2289
- }, `${chalk.default.bold.cyanBright(name)} completed in ${chalk.default.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : (0, date_fns_formatDistanceToNowStrict.formatDistanceToNowStrict)(startDate))}`);
2323
+ this.logger.info({
2324
+ meta: { category: "performance" },
2325
+ message: `${chalk.default.bold.cyanBright(name)} completed in ${chalk.default.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : (0, date_fns_formatDistanceToNowStrict.formatDistanceToNowStrict)(startDate))}`
2326
+ });
2290
2327
  };
2291
2328
  }
2292
2329
  /**
2293
2330
  * Create a new logger instance
2294
2331
  *
2295
- * @param config - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
2296
- * @returns A logger function
2332
+ * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
2333
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
2297
2334
  */
2298
- createLog(config) {
2299
- return (0, _powerlines_core_lib_logger.createLogFn)({
2300
- ...this.options,
2301
- ...config
2302
- });
2335
+ createLogger(options, callback) {
2336
+ return (0, _powerlines_core_plugin_utils_logging.createLogger)(this.options.name || this.options.framework || "powerlines", options, callback);
2303
2337
  }
2304
2338
  /**
2305
- * Extend the current logger instance with a new source
2339
+ * Extend the base logger with additional configuration options
2306
2340
  *
2307
- * @param config - The overlay metadata to use for the badge in the log output, which can be used to customize the appearance and behavior of the log messages generated by the extended logger. This typically includes the name of the plugin or module that is creating the logger instance, and can also include other metadata such as the command or environment.
2308
- * @returns A new logger function that includes the badge in its output.
2341
+ * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
2342
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
2309
2343
  */
2310
- extendLog(config) {
2311
- return (0, _powerlines_core_lib_logger.extendLogFn)(this.log, config);
2344
+ extendLogger(options) {
2345
+ return (0, _powerlines_core_plugin_utils_logging.extendLogger)(this.logger, options);
2312
2346
  }
2313
2347
  /**
2314
- * A logger function specific to this context
2315
- */
2316
- logger;
2317
- /**
2318
2348
  * Initialize the context with the provided configuration options
2319
2349
  *
2320
2350
  * @remarks
@@ -2601,6 +2631,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2601
2631
  }, {}) : this.config.resolve.alias : {});
2602
2632
  }
2603
2633
  /**
2634
+ * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.
2635
+ */
2636
+ get logger() {
2637
+ const options = {
2638
+ ...this.config,
2639
+ ...this.options
2640
+ };
2641
+ const logger = (0, _powerlines_core_plugin_utils.withLogger)((0, _powerlines_core_plugin_utils.createLogger)(this.config.name, options), (0, _powerlines_core_plugin_utils.createLogger)(this.config.name, options, (type, message) => sendWriteLogMessage(this, type, message)));
2642
+ if (this.config.customLogger) return (0, _powerlines_core_plugin_utils.withCustomLogger)(logger, this.config.customLogger);
2643
+ return logger;
2644
+ }
2645
+ /**
2604
2646
  * Gets the parser cache.
2605
2647
  */
2606
2648
  get parserCache() {
@@ -2655,60 +2697,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2655
2697
  this.options = options;
2656
2698
  }
2657
2699
  /**
2658
- * Create a new log function with the specified configuration, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
2659
- *
2660
- * @param config - Optional configuration for the log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
2661
- * @returns A log function that can be used to log messages with the specified configuration.
2662
- */
2663
- createLog(config) {
2664
- const log = (0, _powerlines_core.createLogFn)({
2665
- ...config,
2666
- logLevel: this.logLevel
2667
- });
2668
- return (meta, ...args) => {
2669
- log(meta, ...args);
2670
- process.send?.({
2671
- id: (0, _stryke_unique_id_uuid.uuid)(),
2672
- type: "write-log",
2673
- executionId: config?.executionId ?? this.options.executionId,
2674
- executionIndex: config?.executionIndex ?? this.options.executionIndex,
2675
- timestamp: Date.now(),
2676
- payload: {
2677
- level: meta && (0, _stryke_type_checks_is_set_object.isSetObject)(meta) && (0, _stryke_type_checks_is_set_string.isSetString)(meta.level) ? meta.level : (0, _stryke_type_checks_is_set_string.isSetString)(meta) ? meta : "info",
2678
- ...config,
2679
- args
2680
- }
2681
- });
2682
- };
2683
- }
2684
- /**
2685
- * Extend the current log function instance with a new name
2686
- *
2687
- * @param config - The configuration for the extended log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the log function instance according to your needs.
2688
- * @returns A log function
2689
- */
2690
- extendLog(config) {
2691
- const log = (0, _powerlines_core.extendLogFn)(this.log, {
2692
- ...config,
2693
- logLevel: this.logLevel
2694
- });
2695
- return (meta, ...args) => {
2696
- log(meta, ...args);
2697
- process.send?.({
2698
- id: (0, _stryke_unique_id_uuid.uuid)(),
2699
- type: "write-log",
2700
- executionId: config.executionId ?? this.options.executionId,
2701
- executionIndex: config.executionIndex ?? this.options.executionIndex,
2702
- timestamp: Date.now(),
2703
- payload: {
2704
- level: meta && (0, _stryke_type_checks_is_set_object.isSetObject)(meta) && (0, _stryke_type_checks_is_set_string.isSetString)(meta.level) ? meta.level : (0, _stryke_type_checks_is_set_string.isSetString)(meta) ? meta : "info",
2705
- ...config,
2706
- args
2707
- }
2708
- });
2709
- };
2710
- }
2711
- /**
2712
2700
  * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
2713
2701
  *
2714
2702
  * @remarks
@@ -2751,6 +2739,9 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2751
2739
  headers: cached.headers
2752
2740
  });
2753
2741
  }
2742
+ const logger = this.extendLogger({ category: "network" });
2743
+ const startTime = Date.now();
2744
+ logger.trace(`Sending fetch request (${options.method?.toUpperCase() || "GET"}): ${input.toString()}`);
2754
2745
  const response = await (0, _stryke_http_fetch.fetchRequest)(input, {
2755
2746
  timeout: 12e3,
2756
2747
  ...options
@@ -2764,6 +2755,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2764
2755
  if (!this.config.skipCache && !options.skipCache) try {
2765
2756
  this.requestCache.set(cacheKey, result);
2766
2757
  } catch {}
2758
+ logger.trace(`Fetch request (${options.method?.toUpperCase() || "GET"}) completed in ${Date.now() - startTime}ms: ${input.toString()} - ${response.status} / ${response.statusText} \n - Response Headers: ${JSON.stringify(result.headers)}\n - Response Body: ${typeof result.body === "string" ? result.body.length > 1e3 ? `${result.body.slice(0, 1e3)}... (truncated, total length: ${result.body.length})` : result.body : "[Non-string body]"}`);
2767
2759
  return new undici.Response(result.body, {
2768
2760
  status: result.status,
2769
2761
  statusText: result.statusText,
@@ -3139,6 +3131,13 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3139
3131
  * Initialize the context with the provided configuration options
3140
3132
  */
3141
3133
  async innerSetup() {
3134
+ const logger = this.extendLogger({ category: "config" });
3135
+ logger.debug(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
3136
+ ...(0, _stryke_helpers_omit.omit)(this.config, ["plugins"]),
3137
+ userConfig: this.config.userConfig ? (0, _stryke_helpers_omit.omit)(this.config.userConfig, ["plugins"]) : {},
3138
+ inlineConfig: this.config.inlineConfig ? (0, _stryke_helpers_omit.omit)(this.config.inlineConfig, ["plugins"]) : {},
3139
+ pluginConfig: this.config.pluginConfig ? (0, _stryke_helpers_omit.omit)(this.config.pluginConfig, ["plugins"]) : {}
3140
+ }, null, 2)}`);
3142
3141
  if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
3143
3142
  this.options.mode = "production";
3144
3143
  this.config.mode = "production";
@@ -3210,7 +3209,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3210
3209
  }));
3211
3210
  if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.output?.storage) && this.config.output.storage === "virtual" || (0, _stryke_type_checks_is_set_object.isSetObject)(this.config.output?.storage) && Object.values(this.config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
3212
3211
  this.#fs ??= await VirtualFileSystem.create(this);
3213
- this.extendLog({ category: "config" })("debug", `Resolved Powerlines configuration object: \n${JSON.stringify(this.resolvedConfig, null, 2)}`);
3212
+ logger.debug(`Post-setup Powerlines configuration object: \n${JSON.stringify({
3213
+ ...(0, _stryke_helpers_omit.omit)(this.config, ["plugins"]),
3214
+ userConfig: this.config.userConfig ? (0, _stryke_helpers_omit.omit)(this.config.userConfig, ["plugins"]) : {},
3215
+ inlineConfig: this.config.inlineConfig ? (0, _stryke_helpers_omit.omit)(this.config.inlineConfig, ["plugins"]) : {},
3216
+ pluginConfig: this.config.pluginConfig ? (0, _stryke_helpers_omit.omit)(this.config.pluginConfig, ["plugins"]) : {}
3217
+ }, null, 2)}`);
3214
3218
  }
3215
3219
  };
3216
3220
 
@@ -3260,7 +3264,7 @@ function mergeConfigs(currentResult, previousResults) {
3260
3264
  async function callHook(context, key, options, ...args) {
3261
3265
  const hooks = context.selectHooks(key, options);
3262
3266
  if (hooks.length > 0) {
3263
- context.debug(` 🧩 Calling ${hooks.length} ${chalk.default.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${(0, _powerlines_core_lib_logger.colorText)(hook.plugin.name)}`).join("\n")}`);
3267
+ context.extendLogger({ category: "hooks" }).debug(` 🧩 Calling ${hooks.length} ${chalk.default.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${(0, _powerlines_core_plugin_utils_logging.colorText)(hook.plugin.name)}`).join("\n")}`);
3264
3268
  const invokeHook = async (hook, hookArgs) => {
3265
3269
  return Reflect.apply(hook.handler, hook.context, hookArgs);
3266
3270
  };
@@ -3360,7 +3364,7 @@ function createPluginContext(pluginId, plugin, environment) {
3360
3364
  const normalizeMessage = (message) => {
3361
3365
  return (0, _stryke_type_checks_is_string.isString)(message) ? message : message.message;
3362
3366
  };
3363
- const log = environment.extendLog({ plugin: plugin.name.replaceAll(":", " - ") });
3367
+ const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
3364
3368
  const callHookFn = async (hook, options, ...args) => {
3365
3369
  return environment.$$internal.api.callHook(hook, {
3366
3370
  sequential: true,
@@ -3379,24 +3383,24 @@ function createPluginContext(pluginId, plugin, environment) {
3379
3383
  meta
3380
3384
  };
3381
3385
  if (prop === "id") return pluginId;
3382
- if (prop === "log" || prop === "logger") return log;
3386
+ if (prop === "logger") return logger;
3383
3387
  if (prop === "fatal") return (message) => {
3384
- log("error", normalizeMessage(message));
3388
+ logger.error(normalizeMessage(message));
3385
3389
  };
3386
3390
  if (prop === "error") return (message) => {
3387
- log("error", normalizeMessage(message));
3391
+ logger.error(normalizeMessage(message));
3388
3392
  };
3389
3393
  if (prop === "warn") return (message) => {
3390
- log("warn", normalizeMessage(message));
3394
+ logger.warn(normalizeMessage(message));
3391
3395
  };
3392
3396
  if (prop === "info") return (message) => {
3393
- log("info", normalizeMessage(message));
3397
+ logger.info(normalizeMessage(message));
3394
3398
  };
3395
3399
  if (prop === "debug") return (message) => {
3396
- log("debug", normalizeMessage(message));
3400
+ logger.debug(normalizeMessage(message));
3397
3401
  };
3398
3402
  if (prop === "trace") return (message) => {
3399
- log("trace", normalizeMessage(message));
3403
+ logger.trace(normalizeMessage(message));
3400
3404
  };
3401
3405
  return environment[prop];
3402
3406
  },
@@ -3415,7 +3419,7 @@ function createPluginContext(pluginId, plugin, environment) {
3415
3419
  "addPlugin",
3416
3420
  "selectHooks"
3417
3421
  ].includes(prop)) {
3418
- log("warn", `Cannot set read-only property "${String(prop)}"`);
3422
+ logger.warn(`Cannot set the read-only "${String(prop)}" property`);
3419
3423
  return false;
3420
3424
  }
3421
3425
  environment[prop] = value;
@@ -3467,26 +3471,26 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
3467
3471
  return this.#hooks;
3468
3472
  }
3469
3473
  /**
3470
- * Create a new log function with the specified configuration, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3474
+ * Create a new logger instance
3471
3475
  *
3472
- * @param config - Optional configuration for the log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3473
- * @returns A log function that can be used to log messages with the specified configuration.
3476
+ * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
3477
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
3474
3478
  */
3475
- createLog(config) {
3476
- return super.createLog({
3477
- ...config,
3479
+ createLogger(options, callback) {
3480
+ return super.createLogger({
3481
+ ...options,
3478
3482
  environment: this.environment?.name
3479
- });
3483
+ }, callback);
3480
3484
  }
3481
3485
  /**
3482
- * Extend the current log function instance with a new name
3486
+ * Extend the base logger with additional configuration options
3483
3487
  *
3484
- * @param config - The configuration for the extended log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the log function instance according to your needs.
3485
- * @returns A log function
3488
+ * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
3489
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
3486
3490
  */
3487
- extendLog(config) {
3488
- return super.extendLog({
3489
- ...config,
3491
+ extendLogger(options) {
3492
+ return super.extendLogger({
3493
+ ...options,
3490
3494
  environment: this.environment?.name
3491
3495
  });
3492
3496
  }
@@ -3672,27 +3676,27 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3672
3676
  super(options);
3673
3677
  }
3674
3678
  /**
3675
- * Create a new log function with the specified configuration, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3679
+ * Create a new logger instance
3676
3680
  *
3677
- * @param config - Optional configuration for the log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3678
- * @returns A log function that can be used to log messages with the specified configuration.
3681
+ * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
3682
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
3679
3683
  */
3680
- createLog(config) {
3681
- return super.createLog({
3682
- ...config,
3684
+ createLogger(options, callback) {
3685
+ return super.createLogger({
3686
+ ...options,
3683
3687
  executionId: this.id,
3684
3688
  executionIndex: this.options.executionIndex
3685
- });
3689
+ }, callback);
3686
3690
  }
3687
3691
  /**
3688
- * Extend the current log function instance with a new name
3692
+ * Extend the base logger with additional configuration options
3689
3693
  *
3690
- * @param config - The configuration for the extended log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the log function instance according to your needs.
3691
- * @returns A log function
3694
+ * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
3695
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
3692
3696
  */
3693
- extendLog(config) {
3694
- return super.extendLog({
3695
- ...config,
3697
+ extendLogger(options) {
3698
+ return super.extendLogger({
3699
+ ...options,
3696
3700
  executionId: this.id,
3697
3701
  executionIndex: this.options.executionIndex
3698
3702
  });
@@ -4561,7 +4565,7 @@ ${formatTypes(code)}
4561
4565
  const timer = api.context.timer("Initialization");
4562
4566
  for (const plugin of api.context.config.plugins.flatMap((p) => (0, _stryke_convert_to_array.toArray)(p)) ?? []) await api.addPlugin(plugin);
4563
4567
  if (api.context.plugins.length === 0) api.context.warn("No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
4564
- else api.context.info(`Loaded ${api.context.plugins.length} ${(0, _stryke_string_format_title_case.titleCase)(api.context.config.framework)} plugin${api.context.plugins.length > 1 ? "s" : ""}: \n${api.context.plugins.map((plugin, index) => ` ${index + 1}. ${(0, _powerlines_core_lib_logger.colorText)(plugin.name)}`).join("\n")}`);
4568
+ else api.context.info(`Loaded ${api.context.plugins.length} ${(0, _stryke_string_format_title_case.titleCase)(api.context.config.framework)} plugin${api.context.plugins.length > 1 ? "s" : ""}: \n${api.context.plugins.map((plugin, index) => ` ${index + 1}. ${(0, _powerlines_core_plugin_utils_logging.colorText)(plugin.name)}`).join("\n")}`);
4565
4569
  const pluginConfig = await api.callHook("config", {
4566
4570
  environment: await api.context.getEnvironment(),
4567
4571
  sequential: true,
@@ -4901,44 +4905,28 @@ ${formatTypes(code)}
4901
4905
  //#endregion
4902
4906
  //#region src/_internal/worker.ts
4903
4907
  async function clean({ options, config }) {
4904
- const execution = await PowerlinesExecution.fromConfig(options, config);
4905
- await execution.clean(config);
4906
- await execution.finalize();
4908
+ await (await PowerlinesExecution.fromConfig(options, config)).clean(config);
4907
4909
  }
4908
4910
  async function prepare({ options, config }) {
4909
- const execution = await PowerlinesExecution.fromConfig(options, config);
4910
- await execution.prepare(config);
4911
- await execution.finalize();
4911
+ await (await PowerlinesExecution.fromConfig(options, config)).prepare(config);
4912
4912
  }
4913
4913
  async function types({ options, config }) {
4914
- const execution = await PowerlinesExecution.fromConfig(options, config);
4915
- await execution.types(config);
4916
- await execution.finalize();
4914
+ await (await PowerlinesExecution.fromConfig(options, config)).types(config);
4917
4915
  }
4918
4916
  async function lint({ options, config }) {
4919
- const execution = await PowerlinesExecution.fromConfig(options, config);
4920
- await execution.lint(config);
4921
- await execution.finalize();
4917
+ await (await PowerlinesExecution.fromConfig(options, config)).lint(config);
4922
4918
  }
4923
4919
  async function test({ options, config }) {
4924
- const execution = await PowerlinesExecution.fromConfig(options, config);
4925
- await execution.test(config);
4926
- await execution.finalize();
4920
+ await (await PowerlinesExecution.fromConfig(options, config)).test(config);
4927
4921
  }
4928
4922
  async function build({ options, config }) {
4929
- const execution = await PowerlinesExecution.fromConfig(options, config);
4930
- await execution.build(config);
4931
- await execution.finalize();
4923
+ await (await PowerlinesExecution.fromConfig(options, config)).build(config);
4932
4924
  }
4933
4925
  async function docs({ options, config }) {
4934
- const execution = await PowerlinesExecution.fromConfig(options, config);
4935
- await execution.docs(config);
4936
- await execution.finalize();
4926
+ await (await PowerlinesExecution.fromConfig(options, config)).docs(config);
4937
4927
  }
4938
4928
  async function deploy({ options, config }) {
4939
- const execution = await PowerlinesExecution.fromConfig(options, config);
4940
- await execution.deploy(config);
4941
- await execution.finalize();
4929
+ await (await PowerlinesExecution.fromConfig(options, config)).deploy(config);
4942
4930
  }
4943
4931
 
4944
4932
  //#endregion