-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make loglevel pub and only alloc when needed #38
Conversation
fn loggingEnabled(level: LogLevel) bool { | ||
const currentLevelInt = extism.get_log_level(); | ||
if (currentLevelInt == std.math.maxInt(i32)) { | ||
return false; | ||
} | ||
|
||
const levelInt = @intFromEnum(level); | ||
if (levelInt >= currentLevelInt) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zshipko, just a second set of eyes on the logic here would be helpful :)
pub fn setErrorFmt(self: Plugin, comptime fmt: []const u8, args: anytype) !void { | ||
const data = try std.fmt.allocPrint(self.allocator, fmt, args); | ||
self.setError(data); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quality of life improvement (relates to #32)
if (loggingEnabled(level)) { | ||
const data = try std.fmt.allocPrint(self.allocator, fmt, args); | ||
self.log(level, data); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quality of life improvement (relates to #32)
Fixes #37
Fixes #32
& relates to dylibso/xtp-zig-bindgen#10