mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Show timestamps in the web UI log console (#1137)
Add a LogEntry type for log entries sent over links and returned by log queries. It names the fields every entry has (level, message, timestamp) and leaves the rest as unknown. The console now prefixes each line with the entry's time in the browser's local time zone, which makes it possible to tell when an error happened after the fact. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba518faa05
commit
b474573633
5 files changed
+47
-16
No files matched your search
@@ -1,9 +1,15 @@
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
import { JsonString, StringEnum, StringKey, plainJson } from "./composites.js";
|
||||
import { levels } from "../logging.js";
|
||||
import { type LogEntry, levels } from "../logging.js";
|
||||
import { ControllerConfig, HostConfig } from "../config/index.js";
|
||||
import { ExternalFactorioVersionSchema, LatestReleasesSchema } from "../external/index.js";
|
||||
|
||||
const LogEntrySchema = Type.Object({
|
||||
"level": StringKey(levels),
|
||||
"message": Type.String(),
|
||||
"timestamp": Type.String(),
|
||||
});
|
||||
|
||||
export class ControllerStopRequest {
|
||||
declare ["constructor"]: typeof ControllerStopRequest;
|
||||
static type = "request" as const;
|
||||
@@ -236,11 +242,11 @@ export class LogQueryRequest {
|
||||
|
||||
static Response = class Response {
|
||||
constructor(
|
||||
public log: object[],
|
||||
public log: LogEntry[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"log": Type.Array(Type.Object({})),
|
||||
"log": Type.Array(LogEntrySchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
@@ -256,14 +262,11 @@ export class LogMessageEvent {
|
||||
static dst = ["controller", "control"] as const;
|
||||
|
||||
constructor(
|
||||
public info: { level: keyof typeof levels, message: string },
|
||||
public info: LogEntry,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"info": Type.Object({
|
||||
"level": StringKey(levels),
|
||||
"message": Type.String(),
|
||||
}),
|
||||
"info": LogEntrySchema,
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
|
||||
Reference in new issue
Block a user