mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
mcp: update logging scope to use mcp instead of app
This commit is contained in:
@@ -559,7 +559,7 @@ fn parseMcpArgs(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.fatal(.app, "unknown argument", .{ .mode = "mcp", .arg = opt });
|
log.fatal(.mcp, "unknown argument", .{ .mode = "mcp", .arg = opt });
|
||||||
return error.UnkownOption;
|
return error.UnkownOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
.mcp => {
|
.mcp => {
|
||||||
log.info(.app, "starting MCP server", .{});
|
log.info(.mcp, "starting server", .{});
|
||||||
|
|
||||||
log.opts.format = .logfmt;
|
log.opts.format = .logfmt;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ browser: *lp.Browser,
|
|||||||
session: *lp.Session,
|
session: *lp.Session,
|
||||||
page: *lp.Page,
|
page: *lp.Page,
|
||||||
|
|
||||||
is_running: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
|
is_running: std.atomic.Value(bool) = .init(false),
|
||||||
|
|
||||||
stdout_mutex: std.Thread.Mutex = .{},
|
stdout_mutex: std.Thread.Mutex = .{},
|
||||||
|
|
||||||
@@ -29,12 +29,12 @@ pub fn init(allocator: std.mem.Allocator, app: *App) !*Self {
|
|||||||
self.http_client = try app.http.createClient(allocator);
|
self.http_client = try app.http.createClient(allocator);
|
||||||
errdefer self.http_client.deinit();
|
errdefer self.http_client.deinit();
|
||||||
|
|
||||||
self.notification = try lp.Notification.init(allocator);
|
self.notification = try .init(allocator);
|
||||||
errdefer self.notification.deinit();
|
errdefer self.notification.deinit();
|
||||||
|
|
||||||
self.browser = try allocator.create(lp.Browser);
|
self.browser = try allocator.create(lp.Browser);
|
||||||
errdefer allocator.destroy(self.browser);
|
errdefer allocator.destroy(self.browser);
|
||||||
self.browser.* = try lp.Browser.init(app, .{ .http_client = self.http_client });
|
self.browser.* = try .init(app, .{ .http_client = self.http_client });
|
||||||
errdefer self.browser.deinit();
|
errdefer self.browser.deinit();
|
||||||
|
|
||||||
self.session = try self.browser.newSession(self.notification);
|
self.session = try self.browser.newSession(self.notification);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub fn processRequests(server: *Server) !void {
|
|||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
|
|
||||||
handleMessage(server, arena.allocator(), msg) catch |err| {
|
handleMessage(server, arena.allocator(), msg) catch |err| {
|
||||||
log.err(.app, "MCP Error processing message", .{ .err = err });
|
log.warn(.mcp, "Error processing message", .{ .err = err });
|
||||||
// We should ideally send a parse error response back, but it's hard to extract the ID if parsing failed entirely.
|
// We should ideally send a parse error response back, but it's hard to extract the ID if parsing failed entirely.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -38,14 +38,14 @@ fn handleMessage(server: *Server, arena: std.mem.Allocator, msg: []const u8) !vo
|
|||||||
const parsed = std.json.parseFromSliceLeaky(protocol.Request, arena, msg, .{
|
const parsed = std.json.parseFromSliceLeaky(protocol.Request, arena, msg, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
}) catch |err| {
|
}) catch |err| {
|
||||||
log.err(.app, "MCP JSON Parse Error", .{ .err = err, .msg = msg });
|
log.warn(.mcp, "JSON Parse Error", .{ .err = err, .msg = msg });
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (parsed.id == null) {
|
if (parsed.id == null) {
|
||||||
// It's a notification
|
// It's a notification
|
||||||
if (std.mem.eql(u8, parsed.method, "notifications/initialized")) {
|
if (std.mem.eql(u8, parsed.method, "notifications/initialized")) {
|
||||||
log.info(.app, "MCP Client Initialized", .{});
|
log.info(.mcp, "Client Initialized", .{});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user