Use scoped loggers

This commit is contained in:
Alexandros Naskos 2020-08-14 13:41:34 +03:00
parent 6c4d83d73c
commit 0f54b0e860
5 changed files with 64 additions and 59 deletions

View File

@ -3,6 +3,7 @@ const DocumentStore = @import("document_store.zig");
const ast = std.zig.ast;
const types = @import("types.zig");
const offsets = @import("offsets.zig");
const log = std.log.scoped(.analysis);
/// Get a declaration's doc comment node
fn getDocCommentNode(tree: *ast.Tree, node: *ast.Node) ?*ast.Node.DocComment {
@ -808,7 +809,7 @@ pub fn resolveTypeOfNodeInternal(
const import_str = handle.tree.tokenSlice(import_param.castTag(.StringLiteral).?.token);
const new_handle = (store.resolveImport(handle, import_str[1 .. import_str.len - 1]) catch |err| {
std.log.debug(.analysis, "Error {} while processing import {}\n", .{ err, import_str });
log.debug("Error {} while processing import {}\n", .{ err, import_str });
return null;
}) orelse return null;
@ -833,7 +834,7 @@ pub fn resolveTypeOfNodeInternal(
.type = .{ .data = .{ .other = node }, .is_type_val = false },
.handle = handle,
},
else => {}, //std.log.debug(.analysis, "Type resolution case not implemented; {}\n", .{node.id}),
else => {},
}
return null;
}
@ -1062,7 +1063,7 @@ pub fn getFieldAccessType(
current_type = (try resolveUnwrapOptionalType(store, arena, current_type, &bound_type_params)) orelse return null;
},
else => {
std.log.debug(.analysis, "Unrecognized token {} after period.\n", .{after_period.id});
log.debug("Unrecognized token {} after period.\n", .{after_period.id});
return null;
},
}
@ -1113,7 +1114,7 @@ pub fn getFieldAccessType(
current_type = (try resolveBracketAccessType(store, arena, current_type, if (is_range) .Range else .Single, &bound_type_params)) orelse return null;
},
else => {
std.log.debug(.analysis, "Unimplemented token: {}\n", .{tok.id});
log.debug("Unimplemented token: {}\n", .{tok.id});
return null;
},
}
@ -1160,7 +1161,7 @@ pub fn nodeToString(tree: *ast.Tree, node: *ast.Node) ?[]const u8 {
}
},
else => {
std.log.debug(.analysis, "INVALID: {}\n", .{node.tag});
log.debug("INVALID: {}\n", .{node.tag});
},
}
@ -1980,7 +1981,7 @@ pub const DocumentScope = struct {
pub fn debugPrint(self: DocumentScope) void {
for (self.scopes) |scope| {
std.log.debug(.analysis,
log.debug(
\\--------------------------
\\Scope {}, range: [{}, {})
\\ {} usingnamespaces
@ -1995,10 +1996,10 @@ pub const DocumentScope = struct {
var decl_it = scope.decls.iterator();
var idx: usize = 0;
while (decl_it.next()) |name_decl| : (idx += 1) {
if (idx != 0) std.log.debug(.analysis, ", ", .{});
std.log.debug(.analysis, "{}", .{name_decl.key});
if (idx != 0) log.debug(", ", .{});
log.debug("{}", .{name_decl.key});
}
std.log.debug(.analysis, "\n--------------------------\n", .{});
log.debug("\n--------------------------\n", .{});
}
}

View File

@ -1,6 +1,7 @@
//! This allocator collects information about allocation sizes
const std = @import("std");
const log = std.log.scoped(.debug_alloc);
const DebugAllocator = @This();
@ -134,7 +135,7 @@ fn resize(allocator: *std.mem.Allocator, old_mem: []u8, new_size: usize, len_ali
const self = @fieldParentPtr(DebugAllocator, "allocator", allocator);
if (old_mem.len == 0) {
std.log.debug(.debug_alloc, "Trying to resize empty slice\n", .{});
log.debug("Trying to resize empty slice\n", .{});
std.process.exit(1);
}
@ -157,7 +158,7 @@ fn resize(allocator: *std.mem.Allocator, old_mem: []u8, new_size: usize, len_ali
const curr_allocs = self.info.currentlyAllocated();
if (self.max_bytes != 0 and curr_allocs >= self.max_bytes) {
std.log.debug(.debug_alloc, "Exceeded maximum bytes {}, exiting.\n", .{self.max_bytes});
log.debug("Exceeded maximum bytes {}, exiting.\n", .{self.max_bytes});
std.process.exit(1);
}

View File

@ -3,6 +3,7 @@ const types = @import("types.zig");
const URI = @import("uri.zig");
const analysis = @import("analysis.zig");
const offsets = @import("offsets.zig");
const log = std.log.scoped(.doc_store);
const DocumentStore = @This();
@ -106,7 +107,7 @@ fn loadPackages(context: LoadPackagesContext) !void {
switch (zig_run_result.term) {
.Exited => |exit_code| {
if (exit_code == 0) {
std.log.debug(.doc_store, "Finished zig run for build file {}\n", .{build_file.uri});
log.debug("Finished zig run for build file {}\n", .{build_file.uri});
for (build_file.packages.items) |old_pkg| {
allocator.free(old_pkg.name);
@ -144,7 +145,7 @@ fn loadPackages(context: LoadPackagesContext) !void {
/// This function asserts the document is not open yet and takes ownership
/// of the uri and text passed in.
fn newDocument(self: *DocumentStore, uri: []const u8, text: []u8) anyerror!*Handle {
std.log.debug(.doc_store, "Opened document: {}\n", .{uri});
log.debug("Opened document: {}\n", .{uri});
var handle = try self.allocator.create(Handle);
errdefer self.allocator.destroy(handle);
@ -172,7 +173,7 @@ fn newDocument(self: *DocumentStore, uri: []const u8, text: []u8) anyerror!*Hand
// TODO: Better logic for detecting std or subdirectories?
const in_std = std.mem.indexOf(u8, uri, "/std/") != null;
if (self.zig_exe_path != null and std.mem.endsWith(u8, uri, "/build.zig") and !in_std) {
std.log.debug(.doc_store, "Document is a build file, extracting packages...\n", .{});
log.debug("Document is a build file, extracting packages...\n", .{});
// This is a build file.
var build_file = try self.allocator.create(BuildFile);
errdefer self.allocator.destroy(build_file);
@ -194,7 +195,7 @@ fn newDocument(self: *DocumentStore, uri: []const u8, text: []u8) anyerror!*Hand
.build_runner_path = self.build_runner_path,
.zig_exe_path = self.zig_exe_path.?,
}) catch |err| {
std.log.debug(.doc_store, "Failed to load packages of build file {} (error: {})\n", .{ build_file.uri, err });
log.debug("Failed to load packages of build file {} (error: {})\n", .{ build_file.uri, err });
};
} else if (self.zig_exe_path != null and !in_std) associate_build_file: {
// Look into build files to see if we already have one that fits
@ -202,7 +203,7 @@ fn newDocument(self: *DocumentStore, uri: []const u8, text: []u8) anyerror!*Hand
const build_file_base_uri = build_file.uri[0 .. std.mem.lastIndexOfScalar(u8, build_file.uri, '/').? + 1];
if (std.mem.startsWith(u8, uri, build_file_base_uri)) {
std.log.debug(.doc_store, "Found an associated build file: {}\n", .{build_file.uri});
log.debug("Found an associated build file: {}\n", .{build_file.uri});
build_file.refs += 1;
handle.associated_build_file = build_file;
break :associate_build_file;
@ -254,12 +255,12 @@ fn newDocument(self: *DocumentStore, uri: []const u8, text: []u8) anyerror!*Hand
pub fn openDocument(self: *DocumentStore, uri: []const u8, text: []const u8) !*Handle {
if (self.handles.getEntry(uri)) |entry| {
std.log.debug(.doc_store, "Document already open: {}, incrementing count\n", .{uri});
log.debug("Document already open: {}, incrementing count\n", .{uri});
entry.value.count += 1;
if (entry.value.is_build_file) |build_file| {
build_file.refs += 1;
}
std.log.debug(.doc_store, "New count: {}\n", .{entry.value.count});
log.debug("New count: {}\n", .{entry.value.count});
return entry.value;
}
@ -274,7 +275,7 @@ pub fn openDocument(self: *DocumentStore, uri: []const u8, text: []const u8) !*H
fn decrementBuildFileRefs(self: *DocumentStore, build_file: *BuildFile) void {
build_file.refs -= 1;
if (build_file.refs == 0) {
std.log.debug(.doc_store, "Freeing build file {}\n", .{build_file.uri});
log.debug("Freeing build file {}\n", .{build_file.uri});
for (build_file.packages.items) |pkg| {
self.allocator.free(pkg.name);
self.allocator.free(pkg.uri);
@ -300,7 +301,7 @@ fn decrementCount(self: *DocumentStore, uri: []const u8) void {
if (entry.value.count > 0)
return;
std.log.debug(.doc_store, "Freeing document: {}\n", .{uri});
log.debug("Freeing document: {}\n", .{uri});
if (entry.value.associated_build_file) |build_file| {
self.decrementBuildFileRefs(build_file);
@ -337,7 +338,7 @@ pub fn getHandle(self: *DocumentStore, uri: []const u8) ?*Handle {
// Check if the document text is now sane, move it to sane_text if so.
fn refreshDocument(self: *DocumentStore, handle: *Handle, zig_lib_path: ?[]const u8) !void {
std.log.debug(.doc_store, "New text for document {}\n", .{handle.uri()});
log.debug("New text for document {}\n", .{handle.uri()});
handle.tree.deinit();
handle.tree = try std.zig.parse(self.allocator, handle.document.text);
@ -383,7 +384,7 @@ fn refreshDocument(self: *DocumentStore, handle: *Handle, zig_lib_path: ?[]const
while (idx < still_exist.len) : (idx += 1) {
if (still_exist[idx]) continue;
std.log.debug(.doc_store, "Import removed: {}\n", .{handle.import_uris.items[idx - offset]});
log.debug("Import removed: {}\n", .{handle.import_uris.items[idx - offset]});
const uri = handle.import_uris.orderedRemove(idx - offset);
offset += 1;
@ -400,7 +401,7 @@ pub fn applySave(self: *DocumentStore, handle: *Handle) !void {
.build_runner_path = self.build_runner_path,
.zig_exe_path = self.zig_exe_path.?,
}) catch |err| {
std.log.debug(.doc_store, "Failed to load packages of build file {} (error: {})\n", .{ build_file.uri, err });
log.debug("Failed to load packages of build file {} (error: {})\n", .{ build_file.uri, err });
};
}
}
@ -475,7 +476,7 @@ pub fn uriFromImportStr(
) !?[]const u8 {
if (std.mem.eql(u8, import_str, "std")) {
if (self.std_uri) |uri| return try std.mem.dupe(allocator, u8, uri) else {
std.log.debug(.doc_store, "Cannot resolve std library import, path is null.\n", .{});
log.debug("Cannot resolve std library import, path is null.\n", .{});
return null;
}
} else if (std.mem.eql(u8, import_str, "builtin")) {
@ -513,7 +514,6 @@ pub fn resolveImport(self: *DocumentStore, handle: *Handle, import_str: []const
import_str,
)) orelse return null;
// std.log.debug(.doc_store, "Import final URI: {}\n", .{final_uri});
var consumed_final_uri = false;
defer if (!consumed_final_uri) allocator.free(final_uri);
@ -542,7 +542,7 @@ pub fn resolveImport(self: *DocumentStore, handle: *Handle, import_str: []const
defer allocator.free(file_path);
var file = std.fs.cwd().openFile(file_path, .{}) catch {
std.log.debug(.doc_store, "Cannot open import file {}\n", .{file_path});
log.debug("Cannot open import file {}\n", .{file_path});
return null;
};
@ -553,8 +553,8 @@ pub fn resolveImport(self: *DocumentStore, handle: *Handle, import_str: []const
const file_contents = try allocator.alloc(u8, size);
errdefer allocator.free(file_contents);
file.inStream().readNoEof(file_contents) catch {
std.log.debug(.doc_store, "Could not read from file {}\n", .{file_path});
file.reader().readNoEof(file_contents) catch {
log.debug("Could not read from file {}\n", .{file_path});
return null;
};
@ -575,7 +575,7 @@ fn stdUriFromLibPath(allocator: *std.mem.Allocator, zig_lib_path: ?[]const u8) !
const std_path = std.fs.path.resolve(allocator, &[_][]const u8{
zpath, "./std/std.zig",
}) catch |err| {
std.log.debug(.doc_store, "Failed to resolve zig std library path, error: {}\n", .{err});
log.debug("Failed to resolve zig std library path, error: {}\n", .{err});
return null;
};

View File

@ -14,6 +14,8 @@ const references = @import("references.zig");
const rename = @import("rename.zig");
const offsets = @import("offsets.zig");
const logger = std.log.scoped(.main);
pub const log_level: std.log.Level = switch (std.builtin.mode) {
.Debug => .debug,
else => .notice,
@ -1000,20 +1002,20 @@ fn loadConfig(folder_path: []const u8) ?Config {
const file_buf = folder.readFileAlloc(allocator, "zls.json", 0x1000000) catch |err| {
if (err != error.FileNotFound)
std.log.warn(.main, "Error while reading configuration file: {}\n", .{err});
logger.warn("Error while reading configuration file: {}\n", .{err});
return null;
};
defer allocator.free(file_buf);
// TODO: Better errors? Doesn't seem like std.json can provide us positions or context.
var config = std.json.parse(Config, &std.json.TokenStream.init(file_buf), std.json.ParseOptions{ .allocator = allocator }) catch |err| {
std.log.warn(.main, "Error while parsing configuration file: {}\n", .{err});
logger.warn("Error while parsing configuration file: {}\n", .{err});
return null;
};
if (config.zig_lib_path) |zig_lib_path| {
if (!std.fs.path.isAbsolute(zig_lib_path)) {
std.log.warn(.main, "zig library path is not absolute, defaulting to null.\n", .{});
logger.warn("zig library path is not absolute, defaulting to null.\n", .{});
allocator.free(zig_lib_path);
config.zig_lib_path = null;
}
@ -1080,10 +1082,10 @@ fn initializeHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
if (req.params.workspaceFolders) |workspaceFolders| {
if (workspaceFolders.len != 0) {
std.log.debug(.main, "Got workspace folders in initialization.\n", .{});
logger.debug("Got workspace folders in initialization.\n", .{});
}
for (workspaceFolders) |workspace_folder| {
std.log.debug(.main, "Loaded folder {}\n", .{workspace_folder.uri});
logger.debug("Loaded folder {}\n", .{workspace_folder.uri});
const duped_uri = try std.mem.dupe(allocator, u8, workspace_folder.uri);
try workspace_folder_configs.putNoClobber(duped_uri, null);
}
@ -1099,9 +1101,9 @@ fn initializeHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
});
try respondGeneric(id, response_str);
}
std.log.notice(.main, "zls initialized", .{});
std.log.info(.main, "{}\n", .{client_capabilities});
std.log.notice(.main, "Using offset encoding: {}\n", .{std.meta.tagName(offset_encoding)});
logger.notice("zls initialized", .{});
logger.info("{}\n", .{client_capabilities});
logger.notice("Using offset encoding: {}\n", .{std.meta.tagName(offset_encoding)});
}
var keep_running = true;
@ -1143,7 +1145,7 @@ fn openDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req
fn changeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.ChangeDocument, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.debug(.main, "Trying to change non existent document {}", .{req.params.textDocument.uri});
logger.debug("Trying to change non existent document {}", .{req.params.textDocument.uri});
return;
};
@ -1154,7 +1156,7 @@ fn changeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, r
fn saveDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SaveDocument, config: Config) error{OutOfMemory}!void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to save non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to save non existent document {}", .{req.params.textDocument.uri});
return;
};
try document_store.applySave(handle);
@ -1168,7 +1170,7 @@ fn semanticTokensHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, r
const this_config = configFromUriOr(req.params.textDocument.uri, config);
if (this_config.enable_semantic_tokens) {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to get semantic tokens of non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to get semantic tokens of non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, no_semantic_tokens_response);
};
@ -1185,7 +1187,7 @@ fn semanticTokensHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, r
fn completionHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Completion, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to complete in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to complete in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, no_completions_response);
};
@ -1242,7 +1244,7 @@ fn signatureHelperHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId,
fn gotoHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.GotoDefinition, config: Config, resolve_alias: bool) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to go to definition in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to go to definition in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
@ -1273,7 +1275,7 @@ fn gotoDeclarationHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId,
fn hoverHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Hover, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to get hover in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to get hover in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
@ -1295,7 +1297,7 @@ fn hoverHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: reque
fn documentSymbolsHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.DocumentSymbols, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to get document symbols in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to get document symbols in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
try documentSymbol(arena, id, handle);
@ -1304,7 +1306,7 @@ fn documentSymbolsHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId,
fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Formatting, config: Config) !void {
if (config.zig_exe_path) |zig_exe_path| {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to got to definition in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to got to definition in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
@ -1314,7 +1316,7 @@ fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
process.stdout_behavior = .Pipe;
process.spawn() catch |err| {
std.log.warn(.main, "Failed to spawn zig fmt process, error: {}\n", .{err});
logger.warn("Failed to spawn zig fmt process, error: {}\n", .{err});
return try respondGeneric(id, null_result_response);
};
try process.stdin.?.writeAll(handle.document.text);
@ -1346,7 +1348,7 @@ fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
fn renameHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Rename, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to rename in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to rename in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
@ -1368,7 +1370,7 @@ fn renameHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requ
fn referencesHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.References, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
std.log.warn(.main, "Trying to get references in non existent document {}", .{req.params.textDocument.uri});
logger.warn("Trying to get references in non existent document {}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
@ -1411,7 +1413,7 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso
const start_time = std.time.milliTimestamp();
defer {
const end_time = std.time.milliTimestamp();
std.log.debug(.main, "Took {}ms to process method {}\n", .{ end_time - start_time, method });
logger.debug("Took {}ms to process method {}\n", .{ end_time - start_time, method });
}
const method_map = .{
@ -1452,7 +1454,7 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso
done = extractErr(method_info[2](arena, id, request_obj, config));
} else |err| {
if (err == error.MalformedJson) {
std.log.warn(.main, "Could not create request type {} from JSON {}\n", .{ @typeName(ReqT), json });
logger.warn("Could not create request type {} from JSON {}\n", .{ @typeName(ReqT), json });
}
done = err;
}
@ -1489,7 +1491,7 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso
if (tree.root.Object.get("id")) |_| {
return try respondGeneric(id, not_implemented_response);
}
std.log.debug(.main, "Method without return value not implemented: {}", .{method});
logger.debug("Method without return value not implemented: {}", .{method});
}
var debug_alloc_state: DebugAllocator = undefined;
@ -1563,12 +1565,12 @@ pub fn main() anyerror!void {
break :find_zig;
}
std.log.debug(.main, "zig path `{}` is not absolute, will look in path\n", .{exe_path});
logger.debug("zig path `{}` is not absolute, will look in path\n", .{exe_path});
}
const env_path = std.process.getEnvVarOwned(allocator, "PATH") catch |err| switch (err) {
error.EnvironmentVariableNotFound => {
std.log.warn(.main, "Could not get PATH.\n", .{});
logger.warn("Could not get PATH.\n", .{});
break :find_zig;
},
else => return err,
@ -1589,21 +1591,21 @@ pub fn main() anyerror!void {
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue);
std.log.info(.main, "Found zig in PATH: {}\n", .{zig_exe_path});
logger.info("Found zig in PATH: {}\n", .{zig_exe_path});
break :find_zig;
}
}
if (zig_exe_path) |exe_path| {
config.zig_exe_path = exe_path;
std.log.info(.main, "Using zig executable {}\n", .{exe_path});
logger.info("Using zig executable {}\n", .{exe_path});
if (config.zig_lib_path == null) {
// Set the lib path relative to the executable path.
config.zig_lib_path = try std.fs.path.resolve(allocator, &[_][]const u8{
std.fs.path.dirname(exe_path).?, "./lib/zig",
});
std.log.info(.main, "Resolved standard library from executable: {}\n", .{config.zig_lib_path});
logger.info("Resolved standard library from executable: {}\n", .{config.zig_lib_path});
}
}
@ -1640,7 +1642,7 @@ pub fn main() anyerror!void {
while (keep_running) {
const headers = readRequestHeader(&arena.allocator, reader) catch |err| {
std.log.crit(.main, "{}; exiting!", .{@errorName(err)});
logger.crit("{}; exiting!", .{@errorName(err)});
return;
};
const buf = try arena.allocator.alloc(u8, headers.content_length);
@ -1652,7 +1654,7 @@ pub fn main() anyerror!void {
arena.state = .{};
if (debug_alloc) |dbg| {
std.log.debug(.main, "\n{}\n", .{dbg.info});
logger.debug("\n{}\n", .{dbg.info});
}
}
}

View File

@ -3,6 +3,7 @@ const DocumentStore = @import("document_store.zig");
const analysis = @import("analysis.zig");
const types = @import("types.zig");
const offsets = @import("offsets.zig");
const log = std.log.scoped(.references);
const ast = std.zig.ast;
@ -407,7 +408,7 @@ pub fn symbolReferences(
else => {},
}
} else {
std.log.warn(.references, "Could not find param decl's function", .{});
log.warn("Could not find param decl's function", .{});
return;
};
if (fn_node.getTrailer("body_node")) |body| {