-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.mbt
More file actions
35 lines (31 loc) · 824 Bytes
/
Copy pathhandler.mbt
File metadata and controls
35 lines (31 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
///|
/// Creates a HandlerFn from individual log, flush, and close callbacks.
pub fn make_handler(
log_fn : (LogEntry) -> Unit,
flush_fn : () -> Unit,
close_fn : () -> Unit,
) -> HandlerFn {
{ log_fn, flush_fn, close_fn }
}
///|
/// Function-based log handler dispatching to user-supplied callbacks.
pub(all) struct HandlerFn {
log_fn : (LogEntry) -> Unit
flush_fn : () -> Unit
close_fn : () -> Unit
}
///|
/// Dispatches a log entry to the underlying log callback.
pub fn HandlerFn::log(self : HandlerFn, entry : LogEntry) -> Unit {
(self.log_fn)(entry)
}
///|
/// Flushes the underlying handler callback.
pub fn HandlerFn::flush(self : HandlerFn) -> Unit {
(self.flush_fn)()
}
///|
/// Closes the underlying handler callback.
pub fn HandlerFn::close(self : HandlerFn) -> Unit {
(self.close_fn)()
}