-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_handler.mbt
More file actions
50 lines (45 loc) · 1.08 KB
/
Copy pathmulti_handler.mbt
File metadata and controls
50 lines (45 loc) · 1.08 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
///|
/// Multi-handler that delegates log operations to a list of sub-handlers.
pub(all) struct MultiHandler {
handlers : Array[HandlerFn]
}
///|
/// Creates an empty MultiHandler with no sub-handlers.
pub fn MultiHandler::new() -> MultiHandler {
{ handlers: [] }
}
///|
/// Adds a sub-handler to the multi-handler.
pub fn MultiHandler::add(self : MultiHandler, h : HandlerFn) -> Unit {
self.handlers.push(h)
}
///|
/// Delegates logging to all registered sub-handlers.
pub fn MultiHandler::log(self : MultiHandler, entry : LogEntry) -> Unit {
let n = self.handlers.length()
let mut i = 0
while i < n {
self.handlers[i].log(entry)
i = i + 1
}
}
///|
/// Flushes all registered sub-handlers.
pub fn MultiHandler::flush(self : MultiHandler) -> Unit {
let n = self.handlers.length()
let mut i = 0
while i < n {
self.handlers[i].flush()
i = i + 1
}
}
///|
/// Closes all registered sub-handlers.
pub fn MultiHandler::close(self : MultiHandler) -> Unit {
let n = self.handlers.length()
let mut i = 0
while i < n {
self.handlers[i].close()
i = i + 1
}
}