Skip to content

Commit fdf138b

Browse files
author
root
committed
fix(logging): use local timezone for console log timestamps
formatConsoleLine() used toISOString() which always returns UTC. Reuse the existing formatConsoleTimestamp() from console.ts that correctly formats timestamps using local time. Fixes #25943
1 parent 559b5ea commit fdf138b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/logging/subsystem.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { CHAT_CHANNEL_ORDER } from "../channels/registry.js";
44
import { isVerbose } from "../globals.js";
55
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
66
import { clearActiveProgressLine } from "../terminal/progress-line.js";
7-
import { getConsoleSettings, shouldLogSubsystemToConsole } from "./console.js";
7+
import {
8+
formatConsoleTimestamp,
9+
getConsoleSettings,
10+
shouldLogSubsystemToConsole,
11+
} from "./console.js";
812
import { type LogLevel, levelToMinLevel } from "./levels.js";
913
import { getChildLogger, isFileLogLevelEnabled } from "./logger.js";
1014
import { loggingState } from "./state.js";
@@ -188,7 +192,7 @@ function formatConsoleLine(opts: {
188192
opts.style === "json" ? opts.subsystem : formatSubsystemForConsole(opts.subsystem);
189193
if (opts.style === "json") {
190194
return JSON.stringify({
191-
time: new Date().toISOString(),
195+
time: formatConsoleTimestamp("json"),
192196
level: opts.level,
193197
subsystem: displaySubsystem,
194198
message: opts.message,
@@ -209,10 +213,10 @@ function formatConsoleLine(opts: {
209213
const displayMessage = stripRedundantSubsystemPrefixForConsole(opts.message, displaySubsystem);
210214
const time = (() => {
211215
if (opts.style === "pretty") {
212-
return color.gray(new Date().toISOString().slice(11, 19));
216+
return color.gray(formatConsoleTimestamp("pretty"));
213217
}
214218
if (loggingState.consoleTimestampPrefix) {
215-
return color.gray(new Date().toISOString());
219+
return color.gray(formatConsoleTimestamp(opts.style));
216220
}
217221
return "";
218222
})();

0 commit comments

Comments
 (0)