@ui5/logger 5.0.0-alpha.5 → 5.0.0-alpha.7

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/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
4
4
 
5
5
  A list of unreleased changes can be found [here](https://github.com/SAP/ui5-logger/compare/v4.0.2...HEAD).
6
6
 
7
+ ## [5.0.0-alpha.7](https://github.com/UI5/cli/compare/logger-v5.0.0-alpha.6...logger-v5.0.0-alpha.7) (2026-08-05)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * Refine interactive serve logging and warning messaging ([#1483](https://github.com/UI5/cli/issues/1483)) ([acd707b](https://github.com/UI5/cli/commit/acd707b18ec7c8453b9210307574e837a19cca4d))
13
+ * Show resolved framework version in serve console output ([3210e8b](https://github.com/UI5/cli/commit/3210e8b4f1e212621b03afb6f0b888a32aa19f3e))
14
+
15
+ ## [5.0.0-alpha.6](https://github.com/UI5/cli/compare/logger-v5.0.0-alpha.5...logger-v5.0.0-alpha.6) (2026-07-10)
16
+
17
+
18
+ ### Features
19
+
20
+ * Add live status banner to ui5 serve ([#1439](https://github.com/UI5/cli/issues/1439)) ([2a46c8b](https://github.com/UI5/cli/commit/2a46c8b97f3613314cd61507417f97b079943bce))
21
+
7
22
  ## [5.0.0-alpha.5](https://github.com/UI5/cli/compare/logger-v5.0.0-alpha.4...logger-v5.0.0-alpha.5) (2026-06-24)
8
23
 
9
24
 
@@ -0,0 +1,92 @@
1
+ import prettyHrtime from "pretty-hrtime";
2
+ import Logger from "./Logger.js";
3
+
4
+ /**
5
+ * Logger for emitting status events on the lifecycle of a UI5 development server
6
+ * (idle / stale / settling / building / build-done / error).
7
+ * <br><br>
8
+ * Emits <code>ui5.log</code> and <code>ui5.serve-status</code> events on the
9
+ * [<code>process</code>]{@link https://nodejs.org/api/process.html} object, which can be handled
10
+ * by dedicated writers, like [@ui5/logger/writers/Console]{@link @ui5/logger/writers/Console}
11
+ * or the live banner shipped by <code>@ui5/cli</code>.
12
+ * <br><br>
13
+ * If no listener is attached to the event, messages are written directly to the <code>process.stderr</code> stream.
14
+ *
15
+ * @private
16
+ * @class
17
+ * @alias @ui5/logger/loggers/Serve
18
+ */
19
+ class Serve extends Logger {
20
+ static SERVE_STATUS_EVENT_NAME = "ui5.serve-status";
21
+
22
+ // Emit a `ui5.serve-status` event; if no listener is attached, fall back to
23
+ // a plain log line at the same level. All public status methods route
24
+ // through here so the event payload shape (`{level, status, ...}`) and the
25
+ // no-listener fallback stay in sync across states.
26
+ #emitStatus(status, payload, fallbackMessage, {level = "info"} = {}) {
27
+ const hasListeners = this._emit(Serve.SERVE_STATUS_EVENT_NAME, {
28
+ level,
29
+ status,
30
+ ...payload,
31
+ });
32
+ if (!hasListeners) {
33
+ this._log(level, fallbackMessage);
34
+ }
35
+ }
36
+
37
+ ready() {
38
+ this.#emitStatus("serve-ready", {}, `Server ready`);
39
+ }
40
+
41
+ // Emits the current stale-project set. An empty list means every project is up-to-date.
42
+ stale(staleProjects) {
43
+ if (!staleProjects || !Array.isArray(staleProjects)) {
44
+ throw new Error("loggers/Serve#stale: Missing or incorrect staleProjects parameter");
45
+ }
46
+ this.#emitStatus("serve-stale", {staleProjects},
47
+ staleProjects.length ?
48
+ `Stale projects: ${staleProjects.join(", ")}` :
49
+ `All projects up-to-date`);
50
+ }
51
+
52
+ settling(pendingProjects) {
53
+ if (!pendingProjects || !Array.isArray(pendingProjects)) {
54
+ throw new Error("loggers/Serve#settling: Missing or incorrect pendingProjects parameter");
55
+ }
56
+ this.#emitStatus("serve-settling", {pendingProjects},
57
+ `Waiting for changes to settle in: ${pendingProjects.join(", ")}`);
58
+ }
59
+
60
+ validating(validatingProjects) {
61
+ if (!validatingProjects || !Array.isArray(validatingProjects)) {
62
+ throw new Error(
63
+ "loggers/Serve#validating: Missing or incorrect validatingProjects parameter");
64
+ }
65
+ this.#emitStatus("serve-validating", {validatingProjects},
66
+ `Validating caches for: ${validatingProjects.join(", ")}`);
67
+ }
68
+
69
+ building() {
70
+ this.#emitStatus("serve-building", {}, `Building...`);
71
+ }
72
+
73
+ buildDone(hrtime) {
74
+ if (!Array.isArray(hrtime) || hrtime.length !== 2 ||
75
+ typeof hrtime[0] !== "number" || typeof hrtime[1] !== "number") {
76
+ throw new Error("loggers/Serve#buildDone: Missing or incorrect hrtime parameter");
77
+ }
78
+ this.#emitStatus("serve-build-done", {hrtime},
79
+ `Build finished in ${prettyHrtime(hrtime)}`);
80
+ }
81
+
82
+ // Named serveError rather than error to avoid shadowing Logger.prototype.error
83
+ serveError(error) {
84
+ if (!error) {
85
+ throw new Error("loggers/Serve#serveError: Missing error parameter");
86
+ }
87
+ this.#emitStatus("serve-error", {error},
88
+ `Server error: ${error.message || error}`, {level: "error"});
89
+ }
90
+ }
91
+
92
+ export default Serve;
@@ -3,6 +3,8 @@ import {chalkStderr as chalk} from "chalk";
3
3
  import figures from "figures";
4
4
  import {MultiBar} from "cli-progress";
5
5
  import Logger from "../loggers/Logger.js";
6
+ import {formatLogLine, prefixModuleName} from "./internal/format.js";
7
+ import {REMOTE_CONNECTIONS_WARNING_LINES} from "./interactiveConsole/remoteConnectionsWarning.js";
6
8
 
7
9
  /**
8
10
  * Standard handler for events emitted by @ui5/logger modules. Writes messages to
@@ -29,6 +31,8 @@ class Console {
29
31
  this._handleProjectBuildStatusEvent = this.#handleProjectBuildStatusEvent.bind(this);
30
32
  this._handleBuildMetadataEvent = this.#handleBuildMetadataEvent.bind(this);
31
33
  this._handleProjectBuildMetadataEvent = this.#handleProjectBuildMetadataEvent.bind(this);
34
+ this._handleProjectResolvedEvent = this.#handleProjectResolvedEvent.bind(this);
35
+ this._handleServerListeningEvent = this.#handleServerListeningEvent.bind(this);
32
36
  this._handleStop = this.disable.bind(this);
33
37
  this.#initFiters();
34
38
  }
@@ -109,6 +113,8 @@ class Console {
109
113
  process.on("ui5.project-build-metadata", this._handleProjectBuildMetadataEvent);
110
114
  process.on("ui5.build-status", this._handleBuildStatusEvent);
111
115
  process.on("ui5.project-build-status", this._handleProjectBuildStatusEvent);
116
+ process.on("ui5.project-resolve-succeeded", this._handleProjectResolvedEvent);
117
+ process.on("ui5.server-listening", this._handleServerListeningEvent);
112
118
  process.on("ui5.log.stop-console", this._handleStop);
113
119
  }
114
120
 
@@ -123,6 +129,8 @@ class Console {
123
129
  process.off("ui5.project-build-metadata", this._handleProjectBuildMetadataEvent);
124
130
  process.off("ui5.build-status", this._handleBuildStatusEvent);
125
131
  process.off("ui5.project-build-status", this._handleProjectBuildStatusEvent);
132
+ process.off("ui5.project-resolve-succeeded", this._handleProjectResolvedEvent);
133
+ process.off("ui5.server-listening", this._handleServerListeningEvent);
126
134
  process.off("ui5.log.stop-console", this._handleStop);
127
135
  if (this.#progressBarContainer) {
128
136
  this.#progressBar.stop();
@@ -191,8 +199,7 @@ class Console {
191
199
  if (!Logger.isLevelEnabled(level)) {
192
200
  return;
193
201
  }
194
- const levelPrefix = this.#getLevelPrefix(level);
195
- const msg = `${levelPrefix} ${message}\n`;
202
+ const msg = formatLogLine(level, message) + "\n";
196
203
 
197
204
  if (this.#progressBarContainer) {
198
205
  // If a progress bar is in use, we have to log through it's API
@@ -205,7 +212,7 @@ class Console {
205
212
 
206
213
  #handleLogEvent({level, message, moduleName}) {
207
214
  if (this.#filterModule(moduleName)) {
208
- this.#writeMessage(level, `${chalk.blue(moduleName)} ${message}`);
215
+ this.#writeMessage(level, prefixModuleName(message, moduleName));
209
216
  }
210
217
  }
211
218
 
@@ -427,32 +434,49 @@ class Console {
427
434
  this.#writeMessage(level, `${chalk.blue(`${(projectName)}`)} ${taskIndex}${message}`);
428
435
  }
429
436
 
430
- #getLevelPrefix(level) {
431
- switch (level) {
432
- case "silly":
433
- return chalk.inverse(level);
434
- case "verbose":
435
- return chalk.cyan("verb");
436
- case "perf":
437
- return chalk.bgYellow.red(level);
438
- case "info":
439
- return chalk.green(level);
440
- case "warn":
441
- return chalk.yellow(level);
442
- case "error":
443
- return chalk.bgRed.white(level);
444
- default:
445
- // Log level silent does not produce messages
446
- throw new Error(`writers/Console: Invalid message log level "${level}"`);
437
+ #handleProjectResolvedEvent({name, type, version}) {
438
+ // One-line summary of the root project, mirroring the header region of
439
+ // the interactive writer. Kept as an info line so `ui5 build` and
440
+ // non-TTY `ui5 serve` still record the project identity in scrollback.
441
+ const versionSuffix = version ? ` (${version})` : "";
442
+ const typeLabel = type ? `${type} project ` : "";
443
+ this.#writeMessage("info", `Root project: ${typeLabel}${chalk.bold(name)}${chalk.dim(versionSuffix)}`);
444
+ }
445
+
446
+ #handleServerListeningEvent({urls, acceptRemoteConnections}) {
447
+ if (acceptRemoteConnections) {
448
+ // Emit the warning as chalk-formatted lines on stderr, surrounded
449
+ // by blank lines and without a `warn` level prefix. The interactive
450
+ // writer renders the same lines inside its server region.
451
+ process.stderr.write("\n");
452
+ for (const line of REMOTE_CONNECTIONS_WARNING_LINES) {
453
+ process.stderr.write(line);
454
+ process.stderr.write("\n");
455
+ }
456
+ process.stderr.write("\n");
457
+ }
458
+ // Emit `Server started` and the local URL on stdout without a level
459
+ // prefix — this exact shape is a contract for scripts and users
460
+ // parsing the non-interactive log lines. Network URLs listed under
461
+ // `--accept-remote-connections` are intentionally omitted; the
462
+ // interactive writer is responsible for showing them.
463
+ if (Array.isArray(urls)) {
464
+ const localEntry = urls.find((entry) => entry?.label === "Local") ?? urls[0];
465
+ if (localEntry?.url) {
466
+ process.stdout.write(`Server started\nURL: ${localEntry.url}\n`);
467
+ }
447
468
  }
448
469
  }
449
470
 
450
471
  /**
451
- * Creates a new instance and subscribes it to all events
472
+ * Creates a new instance and subscribes it to all events. Any currently-
473
+ * active console-writing writer is displaced by the `ui5.log.stop-console`
474
+ * event emitted here.
452
475
  *
453
476
  * @public
454
477
  */
455
478
  static init() {
479
+ process.emit("ui5.log.stop-console");
456
480
  const cH = new Console();
457
481
  cH.enable();
458
482
  return cH;