in core/src/main/java/org/apache/jsieve/commands/extensions/Log.java [68:121]
protected Object executeBasic(MailAdapter mail, Arguments arguments,
Block block, SieveContext context) throws SieveException {
String logLevel = null;
String message = null;
// First MAY be a tag argument of fatal, error, warn, info, debug or
// trace.
// default is info.
final ListIterator<Argument> argumentsIter = arguments.getArgumentList().listIterator();
boolean stop = false;
// Tag processing
while (!stop && argumentsIter.hasNext()) {
final Argument argument = argumentsIter.next();
if (argument instanceof TagArgument) {
final String tag = ((TagArgument) argument).getTag();
// LogLevel?
if (null == logLevel
&& (tag.equals(ERROR_TAG)
|| tag.equals(WARN_TAG) || tag.equals(INFO_TAG)
|| tag.equals(DEBUG_TAG) || tag.equals(TRACE_TAG)))
logLevel = tag;
else
throw context.getCoordinate().syntaxException(
"Found unexpected TagArgument");
} else {
// Stop when a non-tag argument is encountered
argumentsIter.previous();
stop = true;
}
}
// Next MUST be a String
if (argumentsIter.hasNext()) {
final Argument argument = argumentsIter.next();
if (argument instanceof StringListArgument) {
List<String> strings = ((StringListArgument) argument).getList();
if (1 == strings.size())
message = strings.get(0);
}
}
if (null == message)
throw context.getCoordinate().syntaxException("Expecting a String");
// Everthing else is an error
if (argumentsIter.hasNext())
throw context.getCoordinate().syntaxException(
"Found unexpected arguments");
log(null == logLevel ? ":info" : logLevel, message, context);
return null;
}