You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/10/02 18:39:27 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log LogTagSupport.java InfoTag.java ErrorTag.java TraceTag.java FatalTag.java DebugTag.java WarnTag.java
jstrachan 2002/10/02 09:39:27
Modified: jelly/src/java/org/apache/commons/jelly/tags/log
LogTagSupport.java InfoTag.java ErrorTag.java
TraceTag.java FatalTag.java DebugTag.java
WarnTag.java
Log:
Allow the logging tags to specify whether their body should be XML encoded as text or not.
By default the body is now not encoded. So if you did
<log:info>hello <b>there</b> how are you?</log:info>
You'd actually get the following message in your log...
hello <b>there</b> how are you?
rather than the XML encoded version with < and > etc.
Revision Changes Path
1.2 +17 -0 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/LogTagSupport.java
Index: LogTagSupport.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/LogTagSupport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LogTagSupport.java 18 Jun 2002 12:27:24 -0000 1.1
+++ LogTagSupport.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -77,6 +77,7 @@
public abstract class LogTagSupport extends TagSupport {
private Log log;
+ private boolean encode;
public LogTagSupport() {
}
@@ -107,4 +108,20 @@
public void setLog(Log log) {
this.log = log;
}
+
+ /**
+ * Returns whether the body of this tag will be XML encoded or not.
+ */
+ public boolean isEncode() {
+ return encode;
+ }
+
+ /**
+ * Sets whether the body of the tag should be encoded as text (so that < and > are
+ * encoded as &lt; and &gt;) or leave the text as XML which is the default.
+ */
+ public void setEncode(boolean encode) {
+ this.encode = encode;
+ }
+
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/InfoTag.java
Index: InfoTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/InfoTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InfoTag.java 18 Jun 2002 12:27:24 -0000 1.1
+++ InfoTag.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -83,7 +83,7 @@
public void doTag(XMLOutput output) throws Exception {
Log log = getLog();
if ( log.isInfoEnabled() ) {
- log.info( getBodyText() );
+ log.info( getBodyText(isEncode()) );
}
}
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/ErrorTag.java
Index: ErrorTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/ErrorTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ErrorTag.java 18 Jun 2002 12:27:24 -0000 1.1
+++ ErrorTag.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -83,7 +83,7 @@
public void doTag(XMLOutput output) throws Exception {
Log log = getLog();
if ( log.isErrorEnabled() ) {
- log.error( getBodyText() );
+ log.error( getBodyText(isEncode()) );
}
}
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/TraceTag.java
Index: TraceTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/TraceTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TraceTag.java 18 Jun 2002 12:27:24 -0000 1.1
+++ TraceTag.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -83,7 +83,7 @@
public void doTag(XMLOutput output) throws Exception {
Log log = getLog();
if ( log.isTraceEnabled() ) {
- log.trace( getBodyText() );
+ log.trace( getBodyText(isEncode()) );
}
}
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/FatalTag.java
Index: FatalTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/FatalTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FatalTag.java 18 Jun 2002 12:27:24 -0000 1.1
+++ FatalTag.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -83,7 +83,7 @@
public void doTag(XMLOutput output) throws Exception {
Log log = getLog();
if ( log.isFatalEnabled() ) {
- log.fatal( getBodyText() );
+ log.fatal( getBodyText(isEncode()) );
}
}
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/DebugTag.java
Index: DebugTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/DebugTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DebugTag.java 18 Jun 2002 12:27:24 -0000 1.1
+++ DebugTag.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -83,7 +83,7 @@
public void doTag(XMLOutput output) throws Exception {
Log log = getLog();
if ( log.isDebugEnabled() ) {
- log.debug( getBodyText() );
+ log.debug( getBodyText(isEncode()) );
}
}
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/WarnTag.java
Index: WarnTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/log/WarnTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WarnTag.java 18 Jun 2002 12:27:24 -0000 1.1
+++ WarnTag.java 2 Oct 2002 16:39:26 -0000 1.2
@@ -83,7 +83,7 @@
public void doTag(XMLOutput output) throws Exception {
Log log = getLog();
if ( log.isWarnEnabled() ) {
- log.warn( getBodyText() );
+ log.warn( getBodyText(isEncode()) );
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>