001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.rewriter.util;
006:
007: import com.sun.portal.rewriter.RewriterLogger;
008: import com.sun.portal.rewriter.RewriterModule;
009:
010: import java.util.logging.Level;
011: import java.util.logging.Logger;
012:
013: /**
014: * @version 1.0 12/15/2001
015: * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
016: */
017: public final class Debug {
018: private final static Logger debugRest;
019: private final static Logger debugRuleSetInfo;
020: private final static Logger debugURI;
021: private final static Logger debugOriginalPage;
022: private final static Logger debugUnaffectedPage;
023: private final static Logger debugRewrittenPage;
024:
025: /*private final static RewriterLogger debugRest;
026: private final static RewriterLogger debugRuleSetInfo;
027: private final static RewriterLogger debugURI;
028: private final static RewriterLogger debugOriginalPage;
029: private final static RewriterLogger debugUnaffectedPage;
030: private final static RewriterLogger debugRewrittenPage;*/
031:
032: static {
033: /*debugRest = Logger.getLogger( RewriterModule.REWRITER_LOG_REST );
034: debugRuleSetInfo = Logger.getLogger( RewriterModule.REWRITER_LOG_RULRESET_INFO );
035: debugURI = Logger.getLogger( RewriterModule.REWRITER_LOG_URI_INFO );
036: debugOriginalPage = Logger.getLogger( RewriterModule.REWRITER_LOG_ORIGINAL_PAGES );
037: debugUnaffectedPage = Logger.getLogger( RewriterModule.REWRITER_LOG_UNAFFECTED_PAGES );
038: debugRewrittenPage = Logger.getLogger( RewriterModule.REWRITER_LOG_REWRITTEN_PAGES );
039: */
040: debugRest = RewriterLogger
041: .getLogger(RewriterModule.REWRITER_LOG_REST);
042: debugRuleSetInfo = RewriterLogger
043: .getLogger(RewriterModule.REWRITER_LOG_RULRESET_INFO);
044: debugURI = RewriterLogger
045: .getLogger(RewriterModule.REWRITER_LOG_URI_INFO);
046: debugOriginalPage = RewriterLogger
047: .getLogger(RewriterModule.REWRITER_LOG_ORIGINAL_PAGES);
048: debugUnaffectedPage = RewriterLogger
049: .getLogger(RewriterModule.REWRITER_LOG_UNAFFECTED_PAGES);
050: debugRewrittenPage = RewriterLogger
051: .getLogger(RewriterModule.REWRITER_LOG_REWRITTEN_PAGES);
052:
053: /*debugRest.setLevel(java.util.logging.Level.FINEST);
054: debugRuleSetInfo.setLevel(java.util.logging.Level.FINEST);
055: debugURI.setLevel(java.util.logging.Level.FINEST);
056: debugOriginalPage.setLevel(java.util.logging.Level.FINEST);
057: debugUnaffectedPage.setLevel(java.util.logging.Level.FINEST);
058: debugRewrittenPage.setLevel(java.util.logging.Level.FINEST);
059: */
060:
061: //write empty string so that the files get created during the initialization
062: //specially in gateway init, gateway starts in root and then changes to noaccess
063: //so creation of the files should be done during root access mode of gateway
064: {
065: //BugNo:4897071
066: String dummyMSG = "DUMMY_INFO_TO_CREATE_THE_FILE";
067: debugRest.severe(dummyMSG);
068: if (isWarningEnabled() || isMessageEnabled()) {
069: debugRuleSetInfo.warning(dummyMSG);
070: debugURI.warning(dummyMSG);
071: debugOriginalPage.warning(dummyMSG);
072: debugUnaffectedPage.warning(dummyMSG);
073: debugRewrittenPage.warning(dummyMSG);
074: }
075: }
076: }//static block
077:
078: public static void recordRuleSetWarning(final String aRecordRuleSet) {
079: debugRuleSetInfo.warning(aRecordRuleSet);
080: }//recordRuleSetWarning()
081:
082: public static void recordRuleSetWarning(
083: final String aRecordRuleSet, Object[] param) {
084: debugRuleSetInfo.log(Level.WARNING, aRecordRuleSet, param);
085: }//recordRuleSetWarning()
086:
087: public static void recordRuleSetMessage(final String aRecordRuleSet) {
088: debugRuleSetInfo.finest(aRecordRuleSet);
089: }//recordURIMessage()
090:
091: public static void recordURIMessage(final String aRecordURI) {
092: debugURI.finest(aRecordURI);
093: }//recordRuleSetMessage()
094:
095: public static void recordURIMessage(final String aRecordURI,
096: Object[] param) {
097: //debugURI.finest( aRecordURI );
098: debugURI.log(Level.FINEST, aRecordURI, param);
099: }//recordRuleSetMessage()
100:
101: public static void recordURIWarning(final String aRecordURI) {
102: debugURI.warning(aRecordURI);
103: }//recordURIWarning()
104:
105: public static void recordURIWarning(final String aRecordURI,
106: Object[] param) {
107: //debugURI.warning( aRecordURI, param );
108: debugURI.log(Level.WARNING, aRecordURI, param);
109: }//recordURIWarning()
110:
111: public static void recordURIWarning(final String aRecordURI,
112: final Exception e) {
113: debugURI.log(Level.WARNING, aRecordURI, e);
114: }//recordURIWarning()
115:
116: public static void recordOriginalPageMessage(
117: final String aOriginalContent) {
118: debugOriginalPage.finest(aOriginalContent);
119: }//recordOriginalPageMessage()
120:
121: public static void recordOriginalPageMessage(
122: final String aOriginalContent, Object[] param) {
123: debugOriginalPage.log(Level.FINEST, aOriginalContent, param);
124: }//recordOriginalPageMessage()
125:
126: public static void recordOriginalPageWarning(
127: final String aOriginalContent) {
128: debugOriginalPage.warning(aOriginalContent);
129: }//recordOriginalPageWarning()
130:
131: public static void recordOriginalPageWarning(
132: final String aOriginalContent, Object[] param) {
133: debugOriginalPage.log(Level.WARNING, aOriginalContent, param);
134: }//recordOriginalPageWarning()
135:
136: public static void recordOriginalPageWarning(
137: final String aOriginalContent, final Exception e) {
138: debugOriginalPage.log(Level.WARNING, aOriginalContent, e);
139: }//recordOriginalPageWarning()
140:
141: public static void recordRewrittenPageMessage(
142: final String aRewrittenContent) {
143: debugRewrittenPage.finest(aRewrittenContent);
144: }//recordRewrittenPageMessage()
145:
146: public static void recordRewrittenPageMessage(
147: final String aRewrittenContent, Object[] param) {
148: debugRewrittenPage.log(Level.FINEST, aRewrittenContent, param);
149: }//recordRewrittenPageMessage()
150:
151: public static void recordUnaffectedPageMessage(
152: final String aRewrittenContent) {
153: debugUnaffectedPage.finest(aRewrittenContent);
154: }//recordUnaffectedPageMessage()
155:
156: public static void recordUnaffectedPageMessage(
157: final String aRewrittenContent, Object[] param) {
158: debugUnaffectedPage.log(Level.FINEST, aRewrittenContent, param);
159: }//recordUnaffectedPageMessage()
160:
161: public static void recordUnaffectedPageWarning(
162: final String aRecordWarning) {
163: debugUnaffectedPage.warning(aRecordWarning);
164: }//recordUnaffectedPageWarning()
165:
166: public static void message(final String msg) {
167: debugRest.finest(msg);
168: }//message()
169:
170: public static void message(final String msg, Object[] param) {
171: debugRest.log(Level.FINEST, msg, param);
172: }//message()
173:
174: public static void warning(final String msg) {
175: debugRest.warning(msg);
176: }//warning()
177:
178: public static void warning(final String msg, Object[] param) {
179: //debugRest.warning( msg );
180: debugRest.log(Level.WARNING, msg, param);
181: }//warning()
182:
183: public static void warning(final String msg, final Throwable t) {
184: debugRest.log(Level.WARNING, msg, t);
185: }//warning()
186:
187: public static void error(final String msg) {
188: debugRest.severe(msg);
189: }//error()
190:
191: public static void error(final String msg, final Throwable t) {
192: debugRest.log(Level.SEVERE, msg, t);
193: }//error()
194:
195: public static void println(final Object msg) {
196: System.out.println(msg);
197: }//println()
198:
199: public static boolean isMessageEnabled() {
200: return debugRest.isLoggable(Level.FINEST);
201: }//isMessageEnabled()
202:
203: public static boolean isWarningEnabled() {
204: return debugRest.isLoggable(Level.WARNING);
205: }//isWarningEnabled()
206:
207: public static boolean isErrorEnabled() {
208: return debugRest.isLoggable(Level.SEVERE);
209: }//isErrorEnabled()
210:
211: public static void main(String[] args) {
212: Debug.error("I am Error");
213: Debug.warning("I am Warning");
214: Debug.message("I am Message");
215: }//main()
216:
217: }//class Debug
|