root/lang/io/Log4Io/io/Log4Io.io

Revision 16743, 1.7 kB (checked in by nowelium, 6 years ago)

lang/io/Log4Io: パッケージに分けてみた

Line 
1Block apply := method(target, args,
2    args = if(args isNil, list(), args)
3    target = if(target isNil, scope, target)
4    self setScope(target)
5    self performWithArgList("call", args)
6)
7Block bind := method(
8    args := call message argsEvaluatedIn(call sender)
9    target := args at(0)
10    args = args slice(1)
11    b := self
12    return block(
13        b apply(target, args union(call message argsEvaluatedIn(call sender)))
14    )
15)
16Block curry := method(
17    args := call message argsEvaluatedIn(call sender)
18    if(args size < 1) then (
19        return self
20    )
21    b := self
22    return block(
23        b apply(scope, args union(call message argsEvaluatedIn(call sender)))
24    )
25)
26
27Log4Io := Object clone do(
28    version := "0.01"
29    applicationStartDate ::= Date clone
30    loggers ::= Map clone
31    import ::= System launchPath
32
33    clone = method(self)
34    init = method(nil)
35
36    getLogger := method(categoryName,
37        if(categoryName isKindOf(Sequence) not) then (
38            categoryName = "root"
39        )
40        if(loggers hasKey(categoryName) not) then (
41            loggers atPut(categoryName, Log4Io Logger with(categoryName))
42        )
43        loggers at(categoryName)
44    )
45    getRootLogger := method(getLogger("root"))
46
47    forward := method(
48        name := call message name
49        file := File with(import .. "/" .. (name) .. ".io")
50        if(file exists) then (
51            self doFile(file path)
52            return self getSlot(name)
53        ) else (
54            Exception raise("Not imported Io: " .. file path)
55        )
56    )
57)
58
59log4ioLogger := Log4Io getLogger("Log4Io")
60log4ioLogger addAppender(Log4Io ConsoleAppender with)
61log4ioLogger setLevel(Log4Io Level ALL)
62
Note: See TracBrowser for help on using the browser.