Repository: logging-log4j2 Updated Branches: refs/heads/master be857478c -> 34ca03cab
LOG4J2-435 small ScriptCondition documentation improvements Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/34ca03ca Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/34ca03ca Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/34ca03ca Branch: refs/heads/master Commit: 34ca03cab16bd32455b8a5afd4ccdca492a8912f Parents: be85747 Author: rpopma <[email protected]> Authored: Sat Dec 5 23:23:35 2015 +0900 Committer: rpopma <[email protected]> Committed: Sat Dec 5 23:23:35 2015 +0900 ---------------------------------------------------------------------- ...g4j-rolling-with-custom-delete-script-fri13th.xml | 15 +++++++-------- src/site/xdoc/manual/appenders.xml | 11 +++++------ 2 files changed, 12 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/34ca03ca/log4j-core/src/test/resources/log4j-rolling-with-custom-delete-script-fri13th.xml ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/resources/log4j-rolling-with-custom-delete-script-fri13th.xml b/log4j-core/src/test/resources/log4j-rolling-with-custom-delete-script-fri13th.xml index e71d1b6..1b1374f 100644 --- a/log4j-core/src/test/resources/log4j-rolling-with-custom-delete-script-fri13th.xml +++ b/log4j-core/src/test/resources/log4j-rolling-with-custom-delete-script-fri13th.xml @@ -33,7 +33,7 @@ <DefaultRolloverStrategy max="100" stopCustomActionsOnError="true"> <Delete basePath="${base}/test" maxDepth="1" followLinks="false"> <ScriptCondition> - <Script name="GroovyCondition" language="groovy"><![CDATA[ + <Script name="superstitious" language="groovy"><![CDATA[ import java.nio.file.*; def result = []; @@ -41,14 +41,13 @@ pathList.each { pathWithAttributes -> def relative = basePath.relativize pathWithAttributes.path - def str = relative.toString(); - statusLogger.trace 'SCRIPT: relative path=' + str + " (base=$basePath)"; + statusLogger.trace 'SCRIPT: relative path=' + relative + " (base=$basePath)"; - // remove files created on Friday the 13th - - def m = pattern.matcher(str); - if (m.find()) { - def dateString = m.group(1); + // remove files dated Friday the 13th + + def matcher = pattern.matcher(relative.toString()); + if (matcher.find()) { + def dateString = matcher.group(1); def calendar = Date.parse("yyyyMMdd", dateString).toCalendar(); def friday13th = calendar.get(Calendar.DAY_OF_MONTH) == 13 \ && calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/34ca03ca/src/site/xdoc/manual/appenders.xml ---------------------------------------------------------------------- diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml index 007f5a6..af5a25a 100644 --- a/src/site/xdoc/manual/appenders.xml +++ b/src/site/xdoc/manual/appenders.xml @@ -2833,7 +2833,7 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity { <DefaultRolloverStrategy> <Delete basePath="${baseDir}" maxDepth="2"> <ScriptCondition> - <Script name="GroovyCondition" language="groovy"><![CDATA[ + <Script name="superstitious" language="groovy"><![CDATA[ import java.nio.file.*; def result = []; @@ -2841,14 +2841,13 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity { pathList.each { pathWithAttributes -> def relative = basePath.relativize pathWithAttributes.path - def str = relative.toString(); - statusLogger.trace 'SCRIPT: relative path=' + str + " (base=$basePath)"; + statusLogger.trace 'SCRIPT: relative path=' + relative + " (base=$basePath)"; // remove files dated Friday the 13th - def m = pattern.matcher(str); - if (m.find()) { - def dateString = m.group(1); + def matcher = pattern.matcher(relative.toString()); + if (matcher.find()) { + def dateString = matcher.group(1); def calendar = Date.parse("yyyyMMdd", dateString).toCalendar(); def friday13th = calendar.get(Calendar.DAY_OF_MONTH) == 13 \ && calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY;
