Skip to content

Commit e413393

Browse files
committed
sdl2.zig improve log message too long error message
1 parent 9927935 commit e413393

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

src/sdl2.zig

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ pub fn log(comptime fmt: []const u8, args: anytype) void {
158158
var buf: [max_log_message]u8 = undefined;
159159
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
160160
std.fmt.BufPrintError.NoSpaceLeft => {
161-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
161+
SDL_LogError(
162+
@intFromEnum(LogCategory.assert),
163+
"(log message exceeded %d characters)",
164+
.{max_log_message},
165+
);
162166
return;
163167
},
164168
};
@@ -172,7 +176,11 @@ pub fn logVerbose(category: LogCategory, comptime fmt: []const u8, args: anytype
172176
var buf: [max_log_message]u8 = undefined;
173177
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
174178
std.fmt.BufPrintError.NoSpaceLeft => {
175-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
179+
SDL_LogError(
180+
@intFromEnum(LogCategory.assert),
181+
"(log message exceeded %d characters)",
182+
.{max_log_message},
183+
);
176184
return;
177185
},
178186
};
@@ -186,7 +194,11 @@ pub fn logDebug(category: LogCategory, comptime fmt: []const u8, args: anytype)
186194
var buf: [max_log_message]u8 = undefined;
187195
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
188196
std.fmt.BufPrintError.NoSpaceLeft => {
189-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
197+
SDL_LogError(
198+
@intFromEnum(LogCategory.assert),
199+
"(log message exceeded %d characters)",
200+
.{max_log_message},
201+
);
190202
return;
191203
},
192204
};
@@ -200,7 +212,11 @@ pub fn logInfo(category: LogCategory, comptime fmt: []const u8, args: anytype) v
200212
var buf: [max_log_message]u8 = undefined;
201213
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
202214
std.fmt.BufPrintError.NoSpaceLeft => {
203-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
215+
SDL_LogError(
216+
@intFromEnum(LogCategory.assert),
217+
"(log message exceeded %d characters)",
218+
.{max_log_message},
219+
);
204220
return;
205221
},
206222
};
@@ -214,7 +230,11 @@ pub fn logWarn(category: LogCategory, comptime fmt: []const u8, args: anytype) v
214230
var buf: [max_log_message]u8 = undefined;
215231
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
216232
std.fmt.BufPrintError.NoSpaceLeft => {
217-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
233+
SDL_LogError(
234+
@intFromEnum(LogCategory.assert),
235+
"(log message exceeded %d characters)",
236+
.{max_log_message},
237+
);
218238
return;
219239
},
220240
};
@@ -228,7 +248,11 @@ pub fn logError(category: LogCategory, comptime fmt: []const u8, args: anytype)
228248
var buf: [max_log_message]u8 = undefined;
229249
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
230250
std.fmt.BufPrintError.NoSpaceLeft => {
231-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
251+
SDL_LogError(
252+
@intFromEnum(LogCategory.assert),
253+
"(log message exceeded %d characters)",
254+
.{max_log_message},
255+
);
232256
return;
233257
},
234258
};
@@ -242,7 +266,11 @@ pub fn logCritical(category: LogCategory, comptime fmt: []const u8, args: anytyp
242266
var buf: [max_log_message]u8 = undefined;
243267
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
244268
std.fmt.BufPrintError.NoSpaceLeft => {
245-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
269+
SDL_LogError(
270+
@intFromEnum(LogCategory.assert),
271+
"(log message exceeded %d characters)",
272+
.{max_log_message},
273+
);
246274
return;
247275
},
248276
};
@@ -256,7 +284,11 @@ pub fn logMessage(category: LogCategory, priority: LogPriority, comptime fmt: []
256284
var buf: [max_log_message]u8 = undefined;
257285
const message = std.fmt.bufPrintZ(&buf, fmt, args) catch |err| switch (err) {
258286
std.fmt.BufPrintError.NoSpaceLeft => {
259-
SDL_LogError(@intFromEnum(LogCategory.assert), "Log message too long!");
287+
SDL_LogError(
288+
@intFromEnum(LogCategory.assert),
289+
"(log message exceeded %d characters)",
290+
.{max_log_message},
291+
);
260292
return;
261293
},
262294
};

0 commit comments

Comments
 (0)