hxn

Log

Shared logging for Haxe and Rust libraries. Set level and sink on the app thread. By default Rust records are pulled after native calls and during Loop.sync; flush explicitly when an otherwise idle native worker can produce logs. No worker calls a Haxe sink. Logging does not keep an idle app alive.

Static fields

var level(get, set):LogLevel

Maximum verbosity for both frontends and attached native libraries.

var sink:Null<(LogRecord) -> Void>

Called on the logging thread. Exceptions are contained; null restores console output.

var enabled(default, null):(value:LogLevel) -> Bool

Checks verbosity before preparing an expensive Haxe message.

var error(default, null):(message:Dynamic, ?target:String, ?pos:Null<PosInfos>) -> Void
var warn(default, null):(message:Dynamic, ?target:String, ?pos:Null<PosInfos>) -> Void
var info(default, null):(message:Dynamic, ?target:String, ?pos:Null<PosInfos>) -> Void
var debug(default, null):(message:Dynamic, ?target:String, ?pos:Null<PosInfos>) -> Void
var trace(default, null):(message:Dynamic, ?target:String, ?pos:Null<PosInfos>) -> Void
var after(default, null):(value:T) -> T

Flushes after a native call without allocating a callback around the call.

var boundary(default, null):() -> Void

A frame loop batches diagnostics at Loop.sync instead of polling after every call.

Static methods

function write(value:LogLevel, message:Dynamic, ?target:String, ?pos:Null<PosInfos>):Void

Emits an owned record; disabled messages are not converted to text.

function attach(setLevel:(Int) -> Void, take:() -> Null<Bytes>):Bool

Used by generated bindings; older bindings need no logging exports.

function flush():Void

Delivers one bounded batch per native source on the app's logging thread.