// typed streaming diagnostics preserve the severity selected by each caller. module engine pub enum LogLevel { error = 1 warning = 2 debug = 4 function = 8 } pub type LogCallback = fn (voidptr, LogLevel, string) pub fn (mut handle Handle) set_log_callback(callback LogCallback, context voidptr) ! { handle.check()! handle.log_callback = callback handle.log_context = context } fn (handle &Handle) has_log_callback() bool { return handle != unsafe { nil } && voidptr(handle.log_callback) != unsafe { nil } } fn (handle &Handle) log(level LogLevel, message string) { if handle.has_log_callback() { handle.log_callback(handle.log_context, level, message) } }