mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1880 from lightpanda-io/logfilter-init-slice
LogFilter: init with slice and silence tests
This commit is contained in:
@@ -3523,13 +3523,16 @@ fn asUint(comptime string: anytype) std.meta.Int(
|
|||||||
|
|
||||||
const testing = @import("../testing.zig");
|
const testing = @import("../testing.zig");
|
||||||
test "WebApi: Page" {
|
test "WebApi: Page" {
|
||||||
const filter: testing.LogFilter = .init(.http);
|
const filter: testing.LogFilter = .init(&.{ .http, .js });
|
||||||
defer filter.deinit();
|
defer filter.deinit();
|
||||||
|
|
||||||
try testing.htmlRunner("page", .{});
|
try testing.htmlRunner("page", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
test "WebApi: Frames" {
|
test "WebApi: Frames" {
|
||||||
|
const filter: testing.LogFilter = .init(&.{.js});
|
||||||
|
defer filter.deinit();
|
||||||
|
|
||||||
try testing.htmlRunner("frames", .{});
|
try testing.htmlRunner("frames", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ test "cdp.page: getFrameTree" {
|
|||||||
|
|
||||||
test "cdp.page: captureScreenshot" {
|
test "cdp.page: captureScreenshot" {
|
||||||
const LogFilter = @import("../../testing.zig").LogFilter;
|
const LogFilter = @import("../../testing.zig").LogFilter;
|
||||||
const filter: LogFilter = .init(.not_implemented);
|
const filter: LogFilter = .init(&.{.not_implemented});
|
||||||
defer filter.deinit();
|
defer filter.deinit();
|
||||||
|
|
||||||
var ctx = testing.context();
|
var ctx = testing.context();
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ test "MCP.router - handleMessage - synchronous unit tests" {
|
|||||||
|
|
||||||
// 5. Parse error
|
// 5. Parse error
|
||||||
{
|
{
|
||||||
const filter: testing.LogFilter = .init(.mcp);
|
const filter: testing.LogFilter = .init(&.{.mcp});
|
||||||
defer filter.deinit();
|
defer filter.deinit();
|
||||||
|
|
||||||
try handleMessage(server, aa, "invalid json");
|
try handleMessage(server, aa, "invalid json");
|
||||||
|
|||||||
@@ -616,12 +616,12 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {
|
|||||||
pub const LogFilter = struct {
|
pub const LogFilter = struct {
|
||||||
old_filter: []const log.Scope,
|
old_filter: []const log.Scope,
|
||||||
|
|
||||||
/// Sets the log filter to only include the specified scope.
|
/// Sets the log filter to suppress the specified scope(s).
|
||||||
/// Returns a LogFilter that should be deinitialized to restore previous filters.
|
/// Returns a LogFilter that should be deinitialized to restore previous filters.
|
||||||
pub fn init(comptime scope: log.Scope) LogFilter {
|
pub fn init(comptime scopes: []const log.Scope) LogFilter {
|
||||||
|
comptime std.debug.assert(@TypeOf(scopes) == []const log.Scope);
|
||||||
const old_filter = log.opts.filter_scopes;
|
const old_filter = log.opts.filter_scopes;
|
||||||
const new_filter = comptime &[_]log.Scope{scope};
|
log.opts.filter_scopes = scopes;
|
||||||
log.opts.filter_scopes = new_filter;
|
|
||||||
return .{ .old_filter = old_filter };
|
return .{ .old_filter = old_filter };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user