Mercurial Hosting > luan
diff host/run.luan @ 1628:520707a70379
add host
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 07 Dec 2021 23:29:58 -0700 |
parents | |
children | 48c24eedb8b2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/host/run.luan Tue Dec 07 23:29:58 2021 -0700 @@ -0,0 +1,50 @@ +require "java" +local Luan = require "luan:Luan.luan" +local error = Luan.error +local ipairs = Luan.ipairs or error() +local Number = require "luan:Number.luan" +local long = Number.long or error() +local Logging = require "luan:logging/Logging.luan" + +local log_to_console = false +for _, arg in ipairs{...} do + if arg == "console" then + log_to_console = true + end +end +if not log_to_console then + local LuanLogger = require "java:luan.modules.logging.LuanLogger" + local Layouts = require "java:goodjava.logger.Layouts" + local DateLayout = require "java:goodjava.logger.DateLayout" + local ListLayout = require "java:goodjava.logger.ListLayout" + local Level = require "java:goodjava.logger.Level" + local RollingFileAppender = require "java:goodjava.logger.RollingFileAppender" + local LevelAppender = require "java:goodjava.logger.LevelAppender" + local ListAppender = require "java:goodjava.logger.ListAppender" + + local one_mb = long(1024*1024) + local layout = ListLayout.new(DateLayout.new("yyyy-MM-dd HH:mm:ss,SSS")," ",Layouts.LEVEL_PADDED," ",Layouts.LOGGER," - ",Layouts.MESSAGE,"\n",Layouts.THROWABLE) + + local function new_appender(file,level) + local appender = RollingFileAppender.new(layout, file) + appender.maxFileSize = one_mb + appender = LevelAppender.new(appender,level) + return appender + end + + local err = new_appender("logs/luan_error.log",Level.ERROR) + local warn = new_appender("logs/luan_warn.log",Level.WARN) + local info = new_appender("logs/luan_info.log",Level.INFO) + local appender = ListAppender.new(err,warn,info) + LuanLogger.configure(appender) +end + +local logger = Logging.logger "luanhost-run" + + +local do_file = Luan.do_file or error() +local WebHandler = require "java:luan.host.WebHandler" + +WebHandler.config = require "file:Config.luan" + +do_file "classpath:luan/host/run.luan"