Mercurial Hosting > luan
comparison logging/src/luan/modules/logging/LuanLogger.java @ 214:8e4ef9134362
move time critical logging functions to java
git-svn-id: https://luan-java.googlecode.com/svn/trunk@215 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 11 Jul 2014 06:06:31 +0000 |
parents | |
children | ec016471c6eb |
comparison
equal
deleted
inserted
replaced
213:4a27f24ce2b5 | 214:8e4ef9134362 |
---|---|
1 package luan.modules.logging; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import luan.LuanState; | |
5 import luan.LuanException; | |
6 import luan.LuanTable; | |
7 import luan.LuanJavaFunction; | |
8 | |
9 | |
10 public final class LuanLogger { | |
11 private final Logger logger; | |
12 | |
13 public LuanLogger(Logger logger) { | |
14 this.logger = logger; | |
15 } | |
16 | |
17 public void error(LuanState luan,Object obj) throws LuanException { | |
18 logger.error( luan.toString(obj) ); | |
19 } | |
20 | |
21 public void warn(LuanState luan,Object obj) throws LuanException { | |
22 logger.warn( luan.toString(obj) ); | |
23 } | |
24 | |
25 public void info(LuanState luan,Object obj) throws LuanException { | |
26 logger.info( luan.toString(obj) ); | |
27 } | |
28 | |
29 public void debug(LuanState luan,Object obj) throws LuanException { | |
30 logger.debug( luan.toString(obj) ); | |
31 } | |
32 | |
33 public LuanTable table() { | |
34 LuanTable tbl = new LuanTable(); | |
35 try { | |
36 tbl.put( "error", new LuanJavaFunction( | |
37 LuanLogger.class.getMethod( "error", LuanState.class, Object.class ), this | |
38 ) ); | |
39 tbl.put( "warn", new LuanJavaFunction( | |
40 LuanLogger.class.getMethod( "warn", LuanState.class, Object.class ), this | |
41 ) ); | |
42 tbl.put( "info", new LuanJavaFunction( | |
43 LuanLogger.class.getMethod( "info", LuanState.class, Object.class ), this | |
44 ) ); | |
45 tbl.put( "debug", new LuanJavaFunction( | |
46 LuanLogger.class.getMethod( "debug", LuanState.class, Object.class ), this | |
47 ) ); | |
48 } catch(NoSuchMethodException e) { | |
49 throw new RuntimeException(e); | |
50 } | |
51 return tbl; | |
52 } | |
53 } |