@powerlines/engine 0.43.31 → 0.44.0

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.
@@ -1,11 +1,11 @@
1
- import { t as PowerlinesBaseContext } from "./base-context-SmQ6OfXm.mjs";
1
+ import { t as PowerlinesBaseContext } from "./base-context-D_ZidDDm.mjs";
2
2
  import { a as FileSystem } from "./fs-D1nIP45P.mjs";
3
3
  import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CUgOdyIa.mjs";
4
4
  import { i as getTsconfigFilePath } from "./tsconfig-Cstsoprg.mjs";
5
- import { CACHE_HASH_LENGTH, DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
5
+ import { CACHE_HASH_LENGTH, DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_ENVIRONMENT, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
6
6
  import { getResolutionCombinations, resolve, resolvePackage, resolveSync } from "@stryke/fs/resolve";
7
7
  import { joinPaths } from "@stryke/path/join";
8
- import { LogLevelLabel } from "@storm-software/config-tools/types";
8
+ import { createLogFn, extendLogFn } from "@powerlines/core";
9
9
  import { isSet } from "@stryke/type-checks/is-set";
10
10
  import { isSetObject } from "@stryke/type-checks/is-set-object";
11
11
  import { isString } from "@stryke/type-checks/is-string";
@@ -13,15 +13,14 @@ import { toArray } from "@stryke/convert/to-array";
13
13
  import { isSetString } from "@stryke/type-checks/is-set-string";
14
14
  import { uuid } from "@stryke/unique-id/uuid";
15
15
  import { colorText } from "@powerlines/core/lib/logger";
16
+ import { addPluginHook, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens } from "@powerlines/core/plugin-utils";
16
17
  import { isEqual } from "@stryke/path/is-equal";
17
18
  import { replaceExtension, replacePath } from "@stryke/path/replace";
18
- import { isNull } from "@stryke/type-checks/is-null";
19
19
  import chalk from "chalk";
20
20
  import defu, { createDefu, defu as defu$1 } from "defu";
21
21
  import { joinPaths as joinPaths$1 } from "@stryke/path/join-paths";
22
22
  import { titleCase } from "@stryke/string-format/title-case";
23
23
  import { format } from "@powerlines/core/lib/utilities/format";
24
- import { addPluginHook, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens } from "@powerlines/core/plugin-utils";
25
24
  import { existsSync } from "@stryke/fs/exists";
26
25
  import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
27
26
  import { omit } from "@stryke/helpers/omit";
@@ -30,7 +29,6 @@ import { findFileDotExtensionSafe, findFileExtensionSafe, findFileName, findFile
30
29
  import { isParentPath } from "@stryke/path/is-parent-path";
31
30
  import { isFunction } from "@stryke/type-checks/is-function";
32
31
  import { isObject } from "@stryke/type-checks/is-object";
33
- import { createLog as createLog$1 } from "@powerlines/core";
34
32
  import { readJsonFile } from "@stryke/fs/json";
35
33
  import { deepClone } from "@stryke/helpers/deep-clone";
36
34
  import { getUniqueInputs, isTypeDefinition, resolveInputsSync } from "@powerlines/core/lib/entry";
@@ -472,7 +470,7 @@ var VirtualFileSystem = class VirtualFileSystem {
472
470
  }
473
471
  }));
474
472
  } else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
475
- result.#log(LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
473
+ result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
476
474
  return result;
477
475
  }
478
476
  /**
@@ -506,7 +504,7 @@ var VirtualFileSystem = class VirtualFileSystem {
506
504
  }
507
505
  });
508
506
  } else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
509
- result.#log(LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
507
+ result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
510
508
  return result;
511
509
  }
512
510
  /**
@@ -640,7 +638,10 @@ var VirtualFileSystem = class VirtualFileSystem {
640
638
  return ret;
641
639
  }, {});
642
640
  }
643
- this.#log = context.extendLog("VFS");
641
+ this.#log = context.extendLog({
642
+ source: "VFS",
643
+ category: "fs"
644
+ });
644
645
  }
645
646
  /**
646
647
  * Asynchronously checks if a file exists in the virtual file system (VFS).
@@ -767,7 +768,7 @@ var VirtualFileSystem = class VirtualFileSystem {
767
768
  listSync(path) {
768
769
  let resolvedPath = path;
769
770
  if (resolvedPath.includes("*")) {
770
- this.#log(LogLevelLabel.WARN, `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
771
+ this.#log("warn", `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
771
772
  resolvedPath = stripStars(resolvedPath);
772
773
  }
773
774
  return getUnique(this.#getStorages(resolvedPath, true).map((storage) => storage.adapter.listSync(storage.relativeBase ? storage.base ? appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)).flat().filter(Boolean));
@@ -781,7 +782,7 @@ var VirtualFileSystem = class VirtualFileSystem {
781
782
  async list(path) {
782
783
  let resolvedPath = path;
783
784
  if (resolvedPath.includes("*")) {
784
- this.#log(LogLevelLabel.WARN, `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
785
+ this.#log("warn", `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
785
786
  resolvedPath = stripStars(resolvedPath);
786
787
  }
787
788
  return getUnique((await Promise.all(this.#getStorages(resolvedPath, true).map(async (storage) => storage.adapter.list(storage.relativeBase ? storage.base ? appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)))).flat().filter(Boolean));
@@ -793,7 +794,7 @@ var VirtualFileSystem = class VirtualFileSystem {
793
794
  */
794
795
  async remove(path) {
795
796
  const normalizedPath = this.#normalizePath(path);
796
- this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
797
+ this.#log("trace", `Removing file: ${normalizedPath}`);
797
798
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
798
799
  if (hasFileExtension(normalizedPath)) await adapter.remove(relativeKey);
799
800
  else await adapter.clear(relativeKey);
@@ -811,7 +812,7 @@ var VirtualFileSystem = class VirtualFileSystem {
811
812
  */
812
813
  removeSync(path) {
813
814
  const normalizedPath = this.#normalizePath(path);
814
- this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
815
+ this.#log("trace", `Removing file: ${normalizedPath}`);
815
816
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
816
817
  if (hasFileExtension(normalizedPath)) adapter.removeSync(relativeKey);
817
818
  else adapter.clearSync(relativeKey);
@@ -957,7 +958,7 @@ var VirtualFileSystem = class VirtualFileSystem {
957
958
  const filePath = await this.resolve(path, void 0, { isFile: true });
958
959
  if (!filePath || !this.existsSync(filePath)) return;
959
960
  const { adapter } = this.#getStorage(filePath);
960
- this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
961
+ this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
961
962
  return await adapter.get(filePath) ?? void 0;
962
963
  }
963
964
  /**
@@ -970,7 +971,7 @@ var VirtualFileSystem = class VirtualFileSystem {
970
971
  const filePath = this.resolveSync(path, void 0, { isFile: true });
971
972
  if (!filePath || !this.existsSync(filePath)) return;
972
973
  const { adapter } = this.#getStorage(filePath);
973
- this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
974
+ this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
974
975
  return adapter.getSync(filePath) ?? void 0;
975
976
  }
976
977
  /**
@@ -985,15 +986,15 @@ var VirtualFileSystem = class VirtualFileSystem {
985
986
  const meta = options.meta ?? {};
986
987
  const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
987
988
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
988
- this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
989
+ this.#log("trace", `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
989
990
  let code = data;
990
991
  try {
991
992
  if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
992
993
  } catch (err) {
993
- if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
994
+ if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log("warn", `Failed to format file ${resolvedPath} before writing: ${err.message}`);
994
995
  code = data;
995
996
  }
996
- this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
997
+ this.#log("trace", `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
997
998
  const id = this.#normalizeId(meta.id || resolvedPath);
998
999
  this.metadata[id] = {
999
1000
  type: "normal",
@@ -1016,7 +1017,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1016
1017
  const meta = options.meta ?? {};
1017
1018
  const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
1018
1019
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1019
- this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
1020
+ 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: ${prettyBytes(new Blob(toArray(data)).size)})`);
1020
1021
  const id = this.#normalizeId(meta.id || resolvedPath);
1021
1022
  this.metadata[id] = {
1022
1023
  type: "normal",
@@ -1180,7 +1181,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1180
1181
  async dispose() {
1181
1182
  if (!this.#isDisposed) {
1182
1183
  this.#isDisposed = true;
1183
- this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
1184
+ this.#log("debug", "Disposing virtual file system...");
1184
1185
  await this.remove(joinPaths(this.#context.dataPath, "fs.bin"));
1185
1186
  const message = new capnp.Message();
1186
1187
  const fs = message.initRoot(FileSystem);
@@ -1215,9 +1216,15 @@ var VirtualFileSystem = class VirtualFileSystem {
1215
1216
  await writeFileBuffer(joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1216
1217
  if (!this.#context.config.skipCache) this.resolverCache.save(true);
1217
1218
  await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
1218
- this.#log(LogLevelLabel.TRACE, "Virtual file system has been disposed.");
1219
+ this.#log("trace", "Virtual file system has been disposed.");
1219
1220
  }
1220
1221
  }
1222
+ /**
1223
+ * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.
1224
+ *
1225
+ * @remarks
1226
+ * This method is automatically called when the VFS instance is used within a `using` block, or can be manually invoked to ensure that the VFS state is saved and resources are cleaned up properly.
1227
+ */
1221
1228
  async [Symbol.asyncDispose]() {
1222
1229
  return this.dispose();
1223
1230
  }
@@ -1366,7 +1373,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1366
1373
  buildId: this.#buildId,
1367
1374
  releaseId: this.#releaseId,
1368
1375
  checksum: this.#checksum,
1369
- timestamp: this.timestamp.getTime(),
1376
+ timestamp: this.timestamp,
1370
1377
  rootHash: murmurhash({
1371
1378
  workspaceRoot: this.options?.cwd,
1372
1379
  root: this.config?.root
@@ -1524,6 +1531,60 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1524
1531
  this.options = options;
1525
1532
  }
1526
1533
  /**
1534
+ * 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.
1535
+ *
1536
+ * @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.
1537
+ * @returns A log function that can be used to log messages with the specified configuration.
1538
+ */
1539
+ createLog(config) {
1540
+ const log = createLogFn({
1541
+ ...config,
1542
+ logLevel: this.logLevel
1543
+ });
1544
+ return (meta, ...args) => {
1545
+ log(meta, ...args);
1546
+ process.send?.({
1547
+ id: uuid(),
1548
+ type: "write-log",
1549
+ executionId: config?.executionId ?? this.options.executionId,
1550
+ executionIndex: config?.executionIndex ?? this.options.executionIndex,
1551
+ timestamp: Date.now(),
1552
+ payload: {
1553
+ level: meta && isSetObject(meta) && isSetString(meta.level) ? meta.level : isSetString(meta) ? meta : "info",
1554
+ ...config,
1555
+ args
1556
+ }
1557
+ });
1558
+ };
1559
+ }
1560
+ /**
1561
+ * Extend the current log function instance with a new name
1562
+ *
1563
+ * @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.
1564
+ * @returns A log function
1565
+ */
1566
+ extendLog(config) {
1567
+ const log = extendLogFn(this.log, {
1568
+ ...config,
1569
+ logLevel: this.logLevel
1570
+ });
1571
+ return (meta, ...args) => {
1572
+ log(meta, ...args);
1573
+ process.send?.({
1574
+ id: uuid(),
1575
+ type: "write-log",
1576
+ executionId: config.executionId ?? this.options.executionId,
1577
+ executionIndex: config.executionIndex ?? this.options.executionIndex,
1578
+ timestamp: Date.now(),
1579
+ payload: {
1580
+ level: meta && isSetObject(meta) && isSetString(meta.level) ? meta.level : isSetString(meta) ? meta : "info",
1581
+ ...config,
1582
+ args
1583
+ }
1584
+ });
1585
+ };
1586
+ }
1587
+ /**
1527
1588
  * 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.
1528
1589
  *
1529
1590
  * @remarks
@@ -1933,6 +1994,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1933
1994
  */
1934
1995
  async init(options = {}) {
1935
1996
  await super.init(options);
1997
+ this.options.executionId = options.executionId ?? this.options.executionId;
1936
1998
  this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
1937
1999
  const projectJsonPath = joinPaths(this.options.cwd, this.options.root, "project.json");
1938
2000
  if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
@@ -1962,10 +2024,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1962
2024
  this.config.framework = "powerlines";
1963
2025
  }
1964
2026
  this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
1965
- this.logger = {
1966
- log: this.createLog(this.config.name),
1967
- level: isNull(this.logLevel) ? "silent" : this.logLevel
1968
- };
1969
2027
  this.config.input = getUniqueInputs(this.config.input);
1970
2028
  if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
1971
2029
  this.config.title ??= titleCase(this.config.name);
@@ -1978,11 +2036,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1978
2036
  ret.push(plugin);
1979
2037
  return ret;
1980
2038
  }, []);
1981
- if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = "debug";
1982
- else this.config.logLevel = "info";
1983
- if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.options.cwd, this.options.root);
2039
+ if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
2040
+ else if (this.config.mode === "test") this.config.logLevel = DEFAULT_TEST_LOG_LEVEL;
2041
+ else this.config.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
2042
+ if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.config.cwd, this.config.root);
1984
2043
  else if (this.config.tsconfig) this.config.tsconfig = replacePath(replacePathTokens(this, this.config.tsconfig), this.config.cwd);
1985
- this.resolvedConfig.output = defu(this.resolvedConfig.output ?? {}, {
2044
+ this.resolvedConfig.output = defu(this.config.output ?? {}, {
1986
2045
  path: joinPaths(this.config.root, "dist"),
1987
2046
  copy: { assets: [
1988
2047
  { glob: "LICENSE" },
@@ -2027,6 +2086,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2027
2086
  }));
2028
2087
  if (isSetString(this.config.output?.storage) && this.config.output.storage === "virtual" || isSetObject(this.config.output?.storage) && Object.values(this.config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
2029
2088
  this.#fs ??= await VirtualFileSystem.create(this);
2089
+ this.extendLog({ category: "config" })("debug", `Resolved Powerlines configuration object: \n${JSON.stringify(this.resolvedConfig, null, 2)}`);
2030
2090
  }
2031
2091
  };
2032
2092
 
@@ -2176,7 +2236,7 @@ function createPluginContext(pluginId, plugin, environment) {
2176
2236
  const normalizeMessage = (message) => {
2177
2237
  return isString(message) ? message : message.message;
2178
2238
  };
2179
- const log = environment.extendLog(pluginId, plugin.name.replaceAll(":", " - "));
2239
+ const log = environment.extendLog({ plugin: plugin.name.replaceAll(":", " - ") });
2180
2240
  const callHookFn = async (hook, options, ...args) => {
2181
2241
  return environment.$$internal.api.callHook(hook, {
2182
2242
  sequential: true,
@@ -2197,22 +2257,22 @@ function createPluginContext(pluginId, plugin, environment) {
2197
2257
  if (prop === "id") return pluginId;
2198
2258
  if (prop === "log" || prop === "logger") return log;
2199
2259
  if (prop === "fatal") return (message) => {
2200
- log(LogLevelLabel.FATAL, normalizeMessage(message));
2260
+ log("error", normalizeMessage(message));
2201
2261
  };
2202
2262
  if (prop === "error") return (message) => {
2203
- log(LogLevelLabel.ERROR, normalizeMessage(message));
2263
+ log("error", normalizeMessage(message));
2204
2264
  };
2205
2265
  if (prop === "warn") return (message) => {
2206
- log(LogLevelLabel.WARN, normalizeMessage(message));
2266
+ log("warn", normalizeMessage(message));
2207
2267
  };
2208
2268
  if (prop === "info") return (message) => {
2209
- log(LogLevelLabel.INFO, normalizeMessage(message));
2269
+ log("info", normalizeMessage(message));
2210
2270
  };
2211
2271
  if (prop === "debug") return (message) => {
2212
- log(LogLevelLabel.DEBUG, normalizeMessage(message));
2272
+ log("debug", normalizeMessage(message));
2213
2273
  };
2214
2274
  if (prop === "trace") return (message) => {
2215
- log(LogLevelLabel.TRACE, normalizeMessage(message));
2275
+ log("trace", normalizeMessage(message));
2216
2276
  };
2217
2277
  return environment[prop];
2218
2278
  },
@@ -2231,7 +2291,7 @@ function createPluginContext(pluginId, plugin, environment) {
2231
2291
  "addPlugin",
2232
2292
  "selectHooks"
2233
2293
  ].includes(prop)) {
2234
- log(LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
2294
+ log("warn", `Cannot set read-only property "${String(prop)}"`);
2235
2295
  return false;
2236
2296
  }
2237
2297
  environment[prop] = value;
@@ -2283,52 +2343,28 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2283
2343
  return this.#hooks;
2284
2344
  }
2285
2345
  /**
2286
- * Create a new logger instance
2346
+ * 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.
2287
2347
  *
2288
- * @param source - The source name to use for the logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
2289
- * @returns A logger function
2348
+ * @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.
2349
+ * @returns A log function that can be used to log messages with the specified configuration.
2290
2350
  */
2291
- createLog(source = null) {
2292
- return (level, ...args) => {
2293
- process.send?.({
2294
- id: uuid(),
2295
- type: "write-log",
2296
- executionId: this.options.executionId,
2297
- executionIndex: this.options.executionIndex,
2298
- timestamp: Date.now(),
2299
- payload: {
2300
- level,
2301
- source,
2302
- environment: this.environment?.name,
2303
- args
2304
- }
2305
- });
2306
- };
2351
+ createLog(config) {
2352
+ return super.createLog({
2353
+ ...config,
2354
+ environment: this.environment?.name
2355
+ });
2307
2356
  }
2308
2357
  /**
2309
- * Extend the current logger instance with a new name
2358
+ * Extend the current log function instance with a new name
2310
2359
  *
2311
- * @param source - The name of the source to use for the extended logger instance
2312
- * @param plugin - An optional plugin name to use for the extended logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
2313
- * @returns A logger function
2360
+ * @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.
2361
+ * @returns A log function
2314
2362
  */
2315
- extendLog(source, plugin) {
2316
- return (level, ...args) => {
2317
- process.send?.({
2318
- id: uuid(),
2319
- type: "write-log",
2320
- executionId: this.options.executionId,
2321
- executionIndex: this.options.executionIndex,
2322
- timestamp: Date.now(),
2323
- payload: {
2324
- level,
2325
- source,
2326
- plugin,
2327
- environment: this.environment?.name,
2328
- args
2329
- }
2330
- });
2331
- };
2363
+ extendLog(config) {
2364
+ return super.extendLog({
2365
+ ...config,
2366
+ environment: this.environment?.name
2367
+ });
2332
2368
  }
2333
2369
  /**
2334
2370
  * 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.
@@ -2512,31 +2548,30 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2512
2548
  super(options);
2513
2549
  }
2514
2550
  /**
2515
- * Create a new logger instance
2551
+ * 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.
2516
2552
  *
2517
- * @param source - The source name to use for the logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
2518
- * @returns A logger function
2553
+ * @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.
2554
+ * @returns A log function that can be used to log messages with the specified configuration.
2519
2555
  */
2520
- createLog(source = null) {
2521
- const logger = createLog$1(source, {
2522
- ...this.config,
2523
- logLevel: isNull(this.config.logLevel) ? "silent" : this.config.logLevel
2556
+ createLog(config) {
2557
+ return super.createLog({
2558
+ ...config,
2559
+ executionId: this.id,
2560
+ executionIndex: this.options.executionIndex
2561
+ });
2562
+ }
2563
+ /**
2564
+ * Extend the current log function instance with a new name
2565
+ *
2566
+ * @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.
2567
+ * @returns A log function
2568
+ */
2569
+ extendLog(config) {
2570
+ return super.extendLog({
2571
+ ...config,
2572
+ executionId: this.id,
2573
+ executionIndex: this.options.executionIndex
2524
2574
  });
2525
- return (level, ...args) => {
2526
- logger(level, ...args);
2527
- process.send?.({
2528
- id: uuid(),
2529
- type: "write-log",
2530
- executionId: this.id,
2531
- executionIndex: this.options.executionIndex,
2532
- timestamp: Date.now(),
2533
- payload: {
2534
- source,
2535
- level,
2536
- args
2537
- }
2538
- });
2539
- };
2540
2575
  }
2541
2576
  /**
2542
2577
  * 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.
@@ -2640,4 +2675,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2640
2675
 
2641
2676
  //#endregion
2642
2677
  export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
2643
- //# sourceMappingURL=execution-context-C_7IC8er.mjs.map
2678
+ //# sourceMappingURL=execution-context-zedP0h4Z.mjs.map