mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #665 from lightpanda-io/log_debug
Tweak debug logging
This commit is contained in:
@@ -647,11 +647,7 @@ pub const Page = struct {
|
||||
}
|
||||
return error.JsErr;
|
||||
};
|
||||
|
||||
if (builtin.mode == .Debug) {
|
||||
const msg = try res.toString(page.arena);
|
||||
log.debug("eval script {s}: {s}", .{ src, msg });
|
||||
}
|
||||
_ = res;
|
||||
|
||||
if (self.onload) |onload| {
|
||||
_ = page.scope.exec(onload, "script_on_load") catch {
|
||||
|
||||
@@ -25,14 +25,14 @@ const App = @import("app.zig").App;
|
||||
const Platform = @import("runtime/js.zig").Platform;
|
||||
const Browser = @import("browser/browser.zig").Browser;
|
||||
|
||||
const build_config = @import("build_config");
|
||||
const parser = @import("browser/netsurf.zig");
|
||||
const version = @import("build_info").git_commit;
|
||||
|
||||
const log = std.log.scoped(.cli);
|
||||
|
||||
pub const std_options = std.Options{
|
||||
// Set the log level to info
|
||||
.log_level = .info,
|
||||
.log_level = @enumFromInt(@intFromEnum(build_config.log_level)),
|
||||
|
||||
// Define logFn to override the std implementation
|
||||
.logFn = logFn,
|
||||
@@ -59,7 +59,7 @@ pub fn main() !void {
|
||||
return std.process.cleanExit();
|
||||
},
|
||||
.version => {
|
||||
std.debug.print("{s}\n", .{version});
|
||||
std.debug.print("{s}\n", .{build_config.git_commit});
|
||||
return std.process.cleanExit();
|
||||
},
|
||||
else => {},
|
||||
|
||||
@@ -1407,6 +1407,9 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
|
||||
fn generateNamedIndexer(comptime Struct: type, template_proto: v8.ObjectTemplate) void {
|
||||
if (@hasDecl(Struct, "named_get") == false) {
|
||||
if (comptime @import("build_config").log_unknown_properties) {
|
||||
generateDebugNamedIndexer(Struct, template_proto);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const configuration = v8.NamedPropertyHandlerConfiguration{
|
||||
@@ -1441,6 +1444,31 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
template_proto.setNamedProperty(configuration, null);
|
||||
}
|
||||
|
||||
fn generateDebugNamedIndexer(comptime Struct: type, template_proto: v8.ObjectTemplate) void {
|
||||
const configuration = v8.NamedPropertyHandlerConfiguration{
|
||||
.getter = struct {
|
||||
fn callback(c_name: ?*const v8.C_Name, raw_info: ?*const v8.C_PropertyCallbackInfo) callconv(.c) u8 {
|
||||
const info = v8.PropertyCallbackInfo.initFromV8(raw_info);
|
||||
const isolate = info.getIsolate();
|
||||
const context = isolate.getCurrentContext();
|
||||
|
||||
const scope: *Scope = @ptrFromInt(context.getEmbedderData(1).castTo(v8.BigInt).getUint64());
|
||||
|
||||
const property = valueToString(scope.call_arena, .{ .handle = c_name.? }, isolate, context) catch "???";
|
||||
log.debug("unknwon named property {s}.{s}", .{ @typeName(Struct), property });
|
||||
return v8.Intercepted.No;
|
||||
}
|
||||
}.callback,
|
||||
|
||||
// This is really cool. Without this, we'd intercept _all_ properties
|
||||
// even those explicitly set. So, node.length for example would get routed
|
||||
// to our `named_get`, rather than a `get_length`. This might be
|
||||
// useful if we run into a type that we can't model properly in Zig.
|
||||
.flags = v8.PropertyHandlerFlags.OnlyInterceptStrings | v8.PropertyHandlerFlags.NonMasking,
|
||||
};
|
||||
template_proto.setNamedProperty(configuration, null);
|
||||
}
|
||||
|
||||
fn generateUndetectable(comptime Struct: type, template: v8.ObjectTemplate) void {
|
||||
const has_js_call_as_function = @hasDecl(Struct, "jsCallAsFunction");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const build_info = @import("build_info");
|
||||
const build_config = @import("build_config");
|
||||
|
||||
const Thread = std.Thread;
|
||||
const Allocator = std.mem.Allocator;
|
||||
@@ -151,7 +151,7 @@ const LightPandaEvent = struct {
|
||||
try writer.write(builtin.cpu.arch);
|
||||
|
||||
try writer.objectField("version");
|
||||
try writer.write(build_info.git_commit);
|
||||
try writer.write(build_config.git_commit);
|
||||
|
||||
try writer.objectField("event");
|
||||
try writer.write(@tagName(std.meta.activeTag(self.event)));
|
||||
|
||||
Reference in New Issue
Block a user