Merge pull request #301 from lightpanda-io/better-log

Better log
This commit is contained in:
Pierre Tachoire
2024-11-18 14:39:40 +01:00
committed by GitHub
3 changed files with 8 additions and 4 deletions

View File

@@ -563,7 +563,7 @@ pub const Page = struct {
const resp = fetchres.req.response;
log.info("fech script {any}: {d}", .{ u, resp.status });
log.info("fetch script {any}: {d}", .{ u, resp.status });
if (resp.status != .ok) return FetchError.BadStatusCode;

View File

@@ -251,12 +251,12 @@ pub const EventHandler = struct {
Event.toInterface(evt) catch unreachable,
}, &res) catch |e| log.err("event handler error: {any}", .{e});
} else {
data.cbk.trycall(.{event}, &res) catch |e| log.err("event handler error: {any}", .{e});
data.cbk.trycall(.{event}, &res) catch |e| log.err("event handler error (null event): {any}", .{e});
}
// in case of function error, we log the result and the trace.
if (!res.success) {
log.info("event handler error: {s}", .{res.result orelse "unknown"});
log.info("event handler error try catch: {s}", .{res.result orelse "unknown"});
log.debug("{s}", .{res.stack orelse "no stack trace"});
}
}

View File

@@ -382,7 +382,11 @@ pub const XMLHttpRequest = struct {
self.reset(alloc);
self.url = try alloc.dupe(u8, url);
self.uri = std.Uri.parse(self.url.?) catch return DOMError.Syntax;
self.uri = std.Uri.parse(self.url.?) catch |err| {
log.debug("parse url ({s}): {any}", .{ self.url.?, err });
return DOMError.Syntax;
};
log.debug("open url ({s})", .{self.url.?});
self.sync = if (asyn) |b| !b else false;
self.state = OPENED;