Mercurial Hosting > luan
changeset 1365:6617763dfd76
fix logging and lucene backup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 12 Jun 2019 22:16:10 -0600 |
parents | 45363886f256 |
children | ae2321a09723 |
files | src/luan/host/init.luan src/luan/modules/logging/Log4j.java src/luan/modules/lucene/Lucene.luan |
diffstat | 3 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/host/init.luan Wed May 29 19:03:25 2019 -0600 +++ b/src/luan/host/init.luan Wed Jun 12 22:16:10 2019 -0600 @@ -16,9 +16,9 @@ local Level = require "java:org.apache.log4j.Level" local EnhancedPatternLayout = require "java:org.apache.log4j.EnhancedPatternLayout" local RollingFileAppender = require "java:org.apache.log4j.RollingFileAppender" - + local logger = Log4j.getRootLogger() - logger.removeAllAppenders() + Log4j.removeAllAppenders(logger) local layout = EnhancedPatternLayout.new("%d %-5p %c - %m%n") local log_dir = dir.."/site/private/local/logs/"
--- a/src/luan/modules/logging/Log4j.java Wed May 29 19:03:25 2019 -0600 +++ b/src/luan/modules/logging/Log4j.java Wed Jun 12 22:16:10 2019 -0600 @@ -1,6 +1,8 @@ package luan.modules.logging; import java.util.Enumeration; +import java.util.List; +import java.util.ArrayList; import org.apache.log4j.Logger; import org.apache.log4j.LogManager; import org.apache.log4j.Hierarchy; @@ -50,4 +52,18 @@ public static Logger getLogger(Luan luan,String name) { return getLoggerRepository(luan).getLogger(name); } + + // because logger.removeAllAppenders() closes the appenders + public static void removeAllAppenders(Logger logger) { + List<Appender> list = new ArrayList<Appender>(); + for( Enumeration en = logger.getAllAppenders(); en.hasMoreElements(); ) { + Appender appender = (Appender)en.nextElement(); + list.add(appender); + } + for( Appender appender : list ) { + logger.removeAppender(appender); + } + if( logger.getAllAppenders().hasMoreElements() ) + throw new RuntimeException(); + } }
--- a/src/luan/modules/lucene/Lucene.luan Wed May 29 19:03:25 2019 -0600 +++ b/src/luan/modules/lucene/Lucene.luan Wed Jun 12 22:16:10 2019 -0600 @@ -4,6 +4,7 @@ local ipairs = Luan.ipairs or error() local type = Luan.type or error() local set_metatable = Luan.set_metatable or error() +local Boot = require "luan:Boot.luan" local Html = require "luan:Html.luan" local Io = require "luan:Io.luan" local uri = Io.uri or error() @@ -138,6 +139,7 @@ end end ) end + index.zip = Boot.no_security(index.zip) function index.restore(zip_file) java_index.run_in_lock( function() @@ -150,6 +152,7 @@ java_index.reopen() end ) end + index.restore = Boot.no_security(index.restore) local function multi_error() error "multiple lucene instances"