Unify 'Registered x' log message format (#1335)

* Unify 'Registered x' log message format

* Apply review change requests
This commit is contained in:
Krzysztof Wiśniewski 2025-04-23 15:36:22 +02:00 committed by GitHub
parent 05d39a81b8
commit 386ff63903
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 11 deletions

View File

@ -93,6 +93,7 @@ pub fn register(_: []const u8, id: []const u8, zon: ZonElement) u16 {
if(reverseIndices.contains(id)) {
std.log.err("Registered block with id {s} twice!", .{id});
}
_id[size] = allocator.dupe(u8, id);
reverseIndices.put(_id[size], @intCast(size)) catch unreachable;
@ -140,8 +141,9 @@ pub fn register(_: []const u8, id: []const u8, zon: ZonElement) u16 {
});
}
size += 1;
return @intCast(size - 1);
defer size += 1;
std.log.debug("Registered block: {d: >5} '{s}'", .{size, id});
return @intCast(size);
}
fn registerBlockDrop(typ: u16, zon: ZonElement) void {

View File

@ -850,14 +850,16 @@ pub fn globalInit() void {
}
pub fn register(_: []const u8, texturePath: []const u8, replacementTexturePath: []const u8, id: []const u8, zon: ZonElement) *BaseItem {
std.log.info("{s}", .{id});
if(reverseIndices.contains(id)) {
std.log.err("Registered item with id {s} twice!", .{id});
std.log.err("Registered item with id '{s}' twice!", .{id});
}
const newItem = &itemList[itemListSize];
defer itemListSize += 1;
newItem.init(arena.allocator(), texturePath, replacementTexturePath, id, zon);
reverseIndices.put(newItem.id, newItem) catch unreachable;
itemListSize += 1;
std.log.debug("Registered item: {d: >5} '{s}'", .{itemListSize, id});
return newItem;
}
@ -897,7 +899,6 @@ fn loadPixelSources(assetFolder: []const u8, id: []const u8, layerPostfix: []con
}
pub fn registerTool(assetFolder: []const u8, id: []const u8, zon: ZonElement) void {
std.log.info("Registering tool type {s}", .{id});
if(toolTypes.contains(id)) {
std.log.err("Registered tool type with id {s} twice!", .{id});
}
@ -942,6 +943,8 @@ pub fn registerTool(assetFolder: []const u8, id: []const u8, zon: ZonElement) vo
.pixelSources = pixelSources,
.pixelSourcesOverlay = pixelSourcesOverlay,
}) catch unreachable;
std.log.debug("Registered tool: '{s}'", .{id});
}
fn parseRecipeItem(zon: ZonElement) !ItemStack {

View File

@ -22,7 +22,7 @@ pub fn init() void {
.usage = @field(commandList, decl.name).usage,
.exec = &@field(commandList, decl.name).execute,
}) catch unreachable;
std.log.info("Registered Command: /{s}", .{decl.name});
std.log.debug("Registered command: '/{s}'", .{decl.name});
}
}

View File

@ -666,14 +666,15 @@ pub fn deinit() void {
}
pub fn register(id: []const u8, paletteId: u32, zon: ZonElement) void {
std.log.debug("Registered biome: {s}", .{id});
std.debug.assert(!finishedLoading);
var biome: Biome = undefined;
biome.init(id, paletteId, zon);
if(biome.isCave) {
caveBiomes.append(biome);
std.log.debug("Registered cave biome: {d: >5} '{s}'", .{paletteId, id});
} else {
biomes.append(biome);
std.log.debug("Registered surface biome: {d: >5} '{s}'", .{paletteId, id});
}
}

View File

@ -200,20 +200,21 @@ pub fn registerSBB(structures: *std.StringHashMap(ZonElement)) !void {
}
pub fn registerChildBlock(numericId: u16, stringId: []const u8) void {
std.debug.assert(numericId != 0);
const index: u16 = @intCast(childBlockNumericIdMap.count());
childBlockNumericIdMap.put(arenaAllocator.allocator, numericId, index) catch unreachable;
// Take only color name from the ID.
var iterator = std.mem.splitBackwardsScalar(u8, stringId, '/');
const colorName = iterator.first();
childBlockStringId.append(arenaAllocator, arenaAllocator.dupe(u8, colorName));
std.log.debug("Structure child block '{s}' {} ('{s}' {}) ", .{colorName, index, stringId, numericId});
}
pub fn registerBlueprints(blueprints: *std.StringHashMap([]u8)) !void {
std.debug.assert(blueprintCache.capacity() == 0);
originBlockNumericId = main.blocks.parseBlock(originBlockStringId).typ;
std.log.debug("Origin block numeric id: {}", .{originBlockNumericId});
std.debug.assert(originBlockNumericId != 0);
blueprintCache.ensureTotalCapacity(arenaAllocator.allocator, blueprints.count()) catch unreachable;
@ -234,7 +235,7 @@ pub fn registerBlueprints(blueprints: *std.StringHashMap([]u8)) !void {
};
blueprintCache.put(arenaAllocator.allocator, arenaAllocator.dupe(u8, stringId), rotatedBlueprints) catch unreachable;
std.log.debug("Registered blueprint: {s}", .{stringId});
std.log.debug("Registered blueprint: '{s}'", .{stringId});
}
}