always use scoped logs instead of default (#864)

This commit is contained in:
Techatrix 2022-12-29 23:20:12 +00:00 committed by GitHub
parent c6d74dbca5
commit 978e41b8a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -279,7 +279,7 @@ fn garbageCollectionImports(self: *DocumentStore) error{OutOfMemory}!void {
i += 1; i += 1;
continue; continue;
} }
std.log.debug("Closing document {s}", .{handle.uri}); log.debug("Closing document {s}", .{handle.uri});
var kv = self.handles.fetchSwapRemove(handle.uri).?; var kv = self.handles.fetchSwapRemove(handle.uri).?;
kv.value.deinit(self.allocator); kv.value.deinit(self.allocator);
self.allocator.destroy(kv.value); self.allocator.destroy(kv.value);
@ -313,7 +313,7 @@ fn garbageCollectionCImports(self: *DocumentStore) error{OutOfMemory}!void {
.failure => "", .failure => "",
.success => |uri| uri, .success => |uri| uri,
}; };
std.log.debug("Destroying cimport {s}", .{message}); log.debug("Destroying cimport {s}", .{message});
kv.value.deinit(self.allocator); kv.value.deinit(self.allocator);
} }
} }
@ -339,7 +339,7 @@ fn garbageCollectionBuildFiles(self: *DocumentStore) error{OutOfMemory}!void {
continue; continue;
} }
var kv = self.build_files.fetchSwapRemove(hash).?; var kv = self.build_files.fetchSwapRemove(hash).?;
std.log.debug("Destroying build file {s}", .{kv.value.uri}); log.debug("Destroying build file {s}", .{kv.value.uri});
kv.value.deinit(self.allocator); kv.value.deinit(self.allocator);
} }
} }

View File

@ -1475,7 +1475,7 @@ fn kindToSortScore(kind: types.CompletionItemKind) ?[]const u8 {
=> "6_", => "6_",
else => { else => {
std.log.debug(@typeName(types.CompletionItemKind) ++ "{s} has no sort score specified!", .{@tagName(kind)}); log.debug(@typeName(types.CompletionItemKind) ++ "{s} has no sort score specified!", .{@tagName(kind)});
return null; return null;
}, },
}; };
@ -1551,7 +1551,7 @@ fn initializeHandler(server: *Server, request: types.InitializeParams) !types.In
defer tracy_zone.end(); defer tracy_zone.end();
if (request.clientInfo) |clientInfo| { if (request.clientInfo) |clientInfo| {
std.log.info("client is '{s}-{s}'", .{ clientInfo.name, clientInfo.version orelse "<no version>" }); log.info("client is '{s}-{s}'", .{ clientInfo.name, clientInfo.version orelse "<no version>" });
if (std.mem.eql(u8, clientInfo.name, "Sublime Text LSP")) blk: { if (std.mem.eql(u8, clientInfo.name, "Sublime Text LSP")) blk: {
server.config.max_detail_length = 256; server.config.max_detail_length = 256;
@ -1750,7 +1750,7 @@ fn initializedHandler(server: *Server, notification: types.InitializedParams) !v
_ = notification; _ = notification;
if (server.status != .initializing) { if (server.status != .initializing) {
std.log.warn("received a initialized notification but the server has not send a initialize request!", .{}); log.warn("received a initialized notification but the server has not send a initialize request!", .{});
} }
server.status = .initialized; server.status = .initialized;
@ -1870,10 +1870,11 @@ fn handleConfiguration(server: *Server, json: std.json.Value) error{OutOfMemory}
else => @compileError("Not implemented for " ++ @typeName(ft)), else => @compileError("Not implemented for " ++ @typeName(ft)),
}, },
}; };
log.debug("setting configuration option '{s}' to '{any}'", .{ field.name, new_value }); // log.debug("setting configuration option '{s}' to '{any}'", .{ field.name, new_value });
@field(server.config, field.name) = new_value; @field(server.config, field.name) = new_value;
} }
} }
log.debug("{}", .{server.client_capabilities});
configuration.configChanged(server.config, server.allocator, null) catch |err| { configuration.configChanged(server.config, server.allocator, null) catch |err| {
log.err("failed to update configuration: {}", .{err}); log.err("failed to update configuration: {}", .{err});
@ -2865,18 +2866,18 @@ pub fn processJsonRpc(
defer parser.deinit(); defer parser.deinit();
var tree = parser.parse(json) catch { var tree = parser.parse(json) catch {
std.log.err("failed to parse message!", .{}); log.err("failed to parse message!", .{});
return; // maybe panic? return; // maybe panic?
}; };
defer tree.deinit(); defer tree.deinit();
const message = Message.fromJsonValueTree(tree) catch { const message = Message.fromJsonValueTree(tree) catch {
std.log.err("failed to parse message!", .{}); log.err("failed to parse message!", .{});
return; // maybe panic? return; // maybe panic?
}; };
server.processMessage(message) catch |err| { server.processMessage(message) catch |err| {
std.log.err("got {} while processing message!", .{err}); // TODO include message information log.err("got {} while processing message!", .{err}); // TODO include message information
switch (message) { switch (message) {
.RequestMessage => |request| server.sendResponseError(request.id, .{ .RequestMessage => |request| server.sendResponseError(request.id, .{
.code = @errorToInt(err), .code = @errorToInt(err),
@ -2909,7 +2910,7 @@ fn processMessage(server: *Server, message: Message) Error!void {
return; return;
} }
std.log.warn("received response from client with id '{s}' that has no handler!", .{response.id.string}); log.warn("received response from client with id '{s}' that has no handler!", .{response.id.string});
return; return;
}, },
} }