Mercurial Hosting > luan
comparison src/luan/host/WebHandler.java @ 1454:219f2b937f2b
remove log4j
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Mar 2020 14:11:30 -0600 |
parents | b6030fa18839 |
children | e66e3d50b289 |
comparison
equal
deleted
inserted
replaced
1453:928be2a4d565 | 1454:219f2b937f2b |
---|---|
12 import luan.LuanTable; | 12 import luan.LuanTable; |
13 import luan.LuanFunction; | 13 import luan.LuanFunction; |
14 import luan.LuanClosure; | 14 import luan.LuanClosure; |
15 import luan.LuanRuntimeException; | 15 import luan.LuanRuntimeException; |
16 import luan.modules.http.LuanHandler; | 16 import luan.modules.http.LuanHandler; |
17 import luan.modules.logging.Log4j; | 17 import luan.modules.logging.LuanLogger; |
18 | 18 |
19 | 19 |
20 public class WebHandler implements Handler { | 20 public class WebHandler implements Handler { |
21 private static final Logger logger = LoggerFactory.getLogger(WebHandler.class); | 21 private static final Logger logger = LoggerFactory.getLogger(WebHandler.class); |
22 | 22 |
29 | 29 |
30 String logDir = dirStr + "/site/private/local/logs/web"; | 30 String logDir = dirStr + "/site/private/local/logs/web"; |
31 new File(logDir).mkdirs(); | 31 new File(logDir).mkdirs(); |
32 | 32 |
33 Luan luan = new Luan(); | 33 Luan luan = new Luan(); |
34 Log4j.newLoggerRepository(luan); | |
35 initLuan(luan,dirStr,domain); | 34 initLuan(luan,dirStr,domain); |
36 return new LuanHandler(luan,domain); | 35 return new LuanHandler(luan,domain); |
37 } | 36 } |
38 }; | 37 }; |
39 | 38 |
45 if( sitesDir != null ) | 44 if( sitesDir != null ) |
46 throw new RuntimeException("already set"); | 45 throw new RuntimeException("already set"); |
47 if( !new File(dir).exists() ) | 46 if( !new File(dir).exists() ) |
48 throw new RuntimeException(); | 47 throw new RuntimeException(); |
49 sitesDir = dir; | 48 sitesDir = dir; |
49 LuanLogger.initThreadLogging(); | |
50 } | 50 } |
51 | 51 |
52 @Override public Response handle(Request request) { | 52 @Override public Response handle(Request request) { |
53 return domainHandler.handle(request); | 53 return domainHandler.handle(request); |
54 } | 54 } |
57 LuanHandler luanHandler = (LuanHandler)domainHandler.getHandler(domain); | 57 LuanHandler luanHandler = (LuanHandler)domainHandler.getHandler(domain); |
58 return luanHandler.call_rpc(fnName,args); | 58 return luanHandler.call_rpc(fnName,args); |
59 } | 59 } |
60 | 60 |
61 private static void initLuan(Luan luan,String dir,String domain) { | 61 private static void initLuan(Luan luan,String dir,String domain) { |
62 LuanLogger.startThreadLogging(luan); | |
62 try { | 63 try { |
63 LuanFunction fn = Luan.loadClasspath(luan,"luan/host/init.luan"); | 64 LuanFunction fn = Luan.loadClasspath(luan,"luan/host/init.luan"); |
64 fn.call(dir,domain); | 65 fn.call(dir,domain); |
65 } catch(LuanException e) { | 66 } catch(LuanException e) { |
66 throw new LuanRuntimeException(e); | 67 throw new LuanRuntimeException(e); |
68 } finally { | |
69 LuanLogger.endThreadLogging(); | |
67 } | 70 } |
68 security(luan,dir); | 71 security(luan,dir); |
69 } | 72 } |
70 | 73 |
71 public static void removeHandler(String domain) { | 74 public static void removeHandler(String domain) { |