#    Copyright 2013 Red Hat, Inc. and/or its affiliates.
#
#    This file is part of jcliff.
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

name=logging
getContents=/subsystem=logging:read-resource(recursive=true)
client.preprocess.strip=/logging

prefix.modify=modify:/
modify.rule.1=/subsystem=logging${cmdpath(${path(..)})}:write-attribute(name=${name(.)},value=${value(.)})

prefix.remove=remove:/
remove.rule.1=/subsystem=logging${cmdpath(${path(.)})}:remove
remove.refresh=true

prefix.undefine=undefine:/
undefine.rule.1=/subsystem=logging${cmdpath(${path(..)})}:undefine-attribute(name=${name(.)})
undefine.refresh=true


match.addFileHandler=add:/file-handler/*
addFileHandler.precedence=50
addFileHandler.rule=/subsystem=logging/file-handler=${name(.)}:add(file={"path"=>${value(./file/path/.)},"relative-to"=>${value(./file/relative-to/.)}})
addFileHandler.refresh=true

match.modifyFileHandlerFile=modify:/file-handler/*/file
modifyFileHandlerFile.rule=/subsystem=logging/file-handler=${name(..)}:change-file(file={"path"=>${value(path)},"relative-to=>${value(relative-to)}})
modifyFileHandlerFile.precedence=53
modifyFileHandlerFile.refresh=true

match.addConsoleHandler=add:/console-handler/*
addConsoleHandler.precedence=50
addConsoleHandler.rule=/subsystem=logging/console-handler=${name(.)}:add
addConsoleHandler.refresh=true

match.addSyslogHandler=add:/syslog-handler/*
addSyslogHandler.precedence=50
addSyslogHandler.rule=/subsystem=logging/syslog-handler=${name(.)}:add
addSyslogHandler.refresh=true

match.addCustomHandler=add:/custom-handler/*
addCustomHandler.precedence=50
addCustomHandler.rule=/subsystem=logging/custom-handler=${name(.)}:add(class=${value(class)}, module=${value(module)})
addCustomHandler.refresh=true

match.addCustomHandlerProperties=add:/custom-handler/*/properties/*
addCustomHandlerProperties.rule=/subsystem=logging/custom-handler=${name(../..)}:write-attribute(name=properties,value=${value(..)})
addCustomHandlerProperties.refresh=true

match.delCustomHandlerProperties=remove:/custom-handler/*/properties/*
delCustomHandlerProperties.rule=/subsystem=logging/custom-handler=${name(../..)}:write-attribute(name=properties,value=${value(..)})
delCustomHandlerProperties.refresh=true

match.modCustomHandlerProperties=modify:/custom-handler/*/properties/*
modCustomHandlerProperties.rule=/subsystem=logging/custom-handler=${name(../..)}:write-attribute(name=properties,value=${value(..)})
modCustomHandlerProperties.refresh=true

match.addSizeRotatingFileHandler=add:/size-rotating-file-handler/*
addSizeRotatingFileHandler.precedence=70
addSizeRotatingFileHandler.rule=/subsystem=logging/size-rotating-file-handler=${name(.)}:add(file={"path"=>${value(./file/path/.)},"relative-to"=>${value(./file/relative-to)}})
addSizeRotatingFileHandler.refresh=true

match.modifySizeRotatingFileHandlerFile=modify:/size-rotating-file-handler/*/file
modifySizeRotatingFileHandlerFile.rule=/subsystem=logging/size-rotating-file-handler=${name(..)}:change-file(file={"path"=>${value(path)},"relative-to"=>${value(relative-to)}})
modifySizeRotatingFileHandlerFile.precedence=75


match.addPeriodicRotatingFileHandler=add:/periodic-rotating-file-handler/*
addPeriodicRotatingFileHandler.precedence=70
addPeriodicRotatingFileHandler.rule=/subsystem=logging/periodic-rotating-file-handler=${name(.)}:add(file={"path"=>${value(./file/path/.)},"relative-to"=>${value(./file/relative-to)}},suffix=>${value(./suffix)})
addPeriodicRotatingFileHandler.refresh=true

match.modifyPeriodicRotatingFileHandlerFile=modify:/periodic-rotating-file-handler/*/file
modifyPeriodicRotatingFileHandlerFile.rule=/subsystem=logging/periodic-rotating-file-handler=${name(..)}:change-file(file={"path"=>${value(path)},"relative-to"=>${value(relative-to)}})
modifyPeriodicRotatingFileHandlerFile.precedence=75


match.addAsyncHandler=add:/async-handler/*
addAsyncHandler.precedence=100
addAsyncHandler.rule=/subsystem=logging/async-handler=${name(.)}:add(queue-length=${value(queue-length)})
addAsyncHandler.refresh=true

match.addSubhandler=add:/async-handler/*/subhandlers/*
addSubhandler.precedence=105
addSubhandler.rule=/subsystem=logging/async-handler=${name(../..)}:assign-subhandler(name=${name(.)})
addSubhandler.refresh=true

match.addLogger=add:/logger/*
addLogger.rule=/subsystem=logging/logger=${name(.)}:add
addLogger.refresh=true
addLogger.precedence=1000

match.assignLoggerHandler=add:/logger/*/handlers/*
assignLoggerHandler.rule=/subsystem=logging/logger=${name(../..)}:assign-handler(name=${value(.)})
assignLoggerHandler.precedence=1100

match.removeLoggerHandler=remove:/logger/*/handlers/*
removeLoggerHandler.rule=/subsystem=logging/logger=${name(../..)}:unassign-handler(name=${value(.)})
removeLoggerHandler.precedence=1100

match.modifyParentHandlers=modify:/logger/*/use-parent-handlers
modifyParentHandlers.rule=/subsystem=logging/logger=${name(..)}:write-attribute(name="use-parent-handlers",value=${value(.)})
modifyParentHandlers.precedence=1100

match.assignRootLoggerHandler=listAdd:/root-logger/ROOT/handlers/*
assignRootLoggerHandler.rule=/subsystem=logging/root-logger=ROOT:root-logger-assign-handler(name=${name(.)})
assignRootLoggerHandler.precedence=10010

match.removeRootLoggerHandler=listRemove:/root-logger/ROOT/handlers/*
removeRootLoggerHandler.rule=/subsystem=logging/root-logger=ROOT:root-logger-unassign-handler(name=${name(.)})
removeRootLoggerHandler.precedence=10010


