Mercurial Hosting > luan
comparison backup/server.luan @ 1672:8dd8c556c449
backup work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 26 May 2022 21:10:02 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1671:8066b8882732 | 1672:8dd8c556c449 |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local ipairs = Luan.ipairs or error() | |
4 local Io = require "luan:Io.luan" | |
5 | |
6 require "java" | |
7 local File = require "java:java.io.File" | |
8 local BackupServer = require "java:goodjava.lucene.backup.BackupServer" | |
9 local Logging = require "luan:logging/Logging.luan" | |
10 | |
11 local log_to_console = false | |
12 for _, arg in ipairs{...} do | |
13 if arg == "console" then | |
14 log_to_console = true | |
15 end | |
16 end | |
17 if not log_to_console then | |
18 local FileWriter = require "java:java.io.FileWriter" | |
19 local LuanLogger = require "java:luan.modules.logging.LuanLogger" | |
20 local Layouts = require "java:goodjava.logger.Layouts" | |
21 local DateLayout = require "java:goodjava.logger.DateLayout" | |
22 local ListLayout = require "java:goodjava.logger.ListLayout" | |
23 local Level = require "java:goodjava.logger.Level" | |
24 local WriterAppender = require "java:goodjava.logger.WriterAppender" | |
25 local LevelAppender = require "java:goodjava.logger.LevelAppender" | |
26 local ListAppender = require "java:goodjava.logger.ListAppender" | |
27 | |
28 local layout = ListLayout.new(DateLayout.new("yyyy-MM-dd HH:mm:ss,SSS")," ",Layouts.LEVEL_PADDED," ",Layouts.LOGGER," - ",Layouts.MESSAGE,"\n",Layouts.THROWABLE) | |
29 | |
30 local function new_appender(file,level) | |
31 local writer = FileWriter.new(file,true) | |
32 local appender = WriterAppender.new(layout,writer) | |
33 appender = LevelAppender.new(appender,level) | |
34 return appender | |
35 end | |
36 | |
37 Io.uri("file:logs").mkdir() | |
38 local err = new_appender("logs/error.log",Level.ERROR) | |
39 local warn = new_appender("logs/warn.log",Level.WARN) | |
40 local info = new_appender("logs/info.log",Level.INFO) | |
41 local appender = ListAppender.new(err,warn,info) | |
42 LuanLogger.configure(appender) | |
43 end | |
44 | |
45 local dir = File.new("backups") | |
46 local server = BackupServer.new(dir) | |
47 server.start() |