1628
|
1 require "java"
|
|
2 local Luan = require "luan:Luan.luan"
|
|
3 local error = Luan.error
|
|
4 local ipairs = Luan.ipairs or error()
|
|
5 local Number = require "luan:Number.luan"
|
|
6 local long = Number.long or error()
|
|
7 local Logging = require "luan:logging/Logging.luan"
|
|
8
|
|
9 local log_to_console = false
|
|
10 for _, arg in ipairs{...} do
|
|
11 if arg == "console" then
|
|
12 log_to_console = true
|
|
13 end
|
|
14 end
|
|
15 if not log_to_console then
|
|
16 local LuanLogger = require "java:luan.modules.logging.LuanLogger"
|
|
17 local Layouts = require "java:goodjava.logger.Layouts"
|
|
18 local DateLayout = require "java:goodjava.logger.DateLayout"
|
|
19 local ListLayout = require "java:goodjava.logger.ListLayout"
|
|
20 local Level = require "java:goodjava.logger.Level"
|
|
21 local RollingFileAppender = require "java:goodjava.logger.RollingFileAppender"
|
|
22 local LevelAppender = require "java:goodjava.logger.LevelAppender"
|
|
23 local ListAppender = require "java:goodjava.logger.ListAppender"
|
|
24
|
|
25 local one_mb = long(1024*1024)
|
|
26 local layout = ListLayout.new(DateLayout.new("yyyy-MM-dd HH:mm:ss,SSS")," ",Layouts.LEVEL_PADDED," ",Layouts.LOGGER," - ",Layouts.MESSAGE,"\n",Layouts.THROWABLE)
|
|
27
|
|
28 local function new_appender(file,level)
|
|
29 local appender = RollingFileAppender.new(layout, file)
|
|
30 appender.maxFileSize = one_mb
|
|
31 appender = LevelAppender.new(appender,level)
|
|
32 return appender
|
|
33 end
|
|
34
|
|
35 local err = new_appender("logs/luan_error.log",Level.ERROR)
|
|
36 local warn = new_appender("logs/luan_warn.log",Level.WARN)
|
|
37 local info = new_appender("logs/luan_info.log",Level.INFO)
|
|
38 local appender = ListAppender.new(err,warn,info)
|
|
39 LuanLogger.configure(appender)
|
|
40 end
|
|
41
|
|
42 local logger = Logging.logger "luanhost-run"
|
|
43
|
|
44
|
|
45 local do_file = Luan.do_file or error()
|
|
46 local WebHandler = require "java:luan.host.WebHandler"
|
|
47
|
|
48 WebHandler.config = require "file:Config.luan"
|
|
49
|
|
50 do_file "classpath:luan/host/run.luan"
|