mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Tweak debug logging
1 - Add a log_level build option to control the default log level from
the build (e.g. -Dlog_level=debug). Defaults to info
2 - Add a new boolean log_unknown_properties build option to enable
logging unknown properties. Defautls to false.
3 - Remove the log debug for script eval - this can be a huge value
(i.e. hundreds of KB), which makes the debug log unusable IMO.
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user