Mercurial Hosting > luan
view host/run.luan @ 1635:fd3d56f39450
rearrange startup files
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 14 Dec 2021 18:50:43 -0700 |
parents | 520707a70379 |
children | 48c24eedb8b2 |
line wrap: on
line source
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"