Source Code Cross Referenced for AntLog.java in  » Parser » chaperon-3.0 » net » sourceforge » chaperon » ant » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Parser » chaperon 3.0 » net.sourceforge.chaperon.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright (C) Chaperon. All rights reserved.
003:         *  -------------------------------------------------------------------------
004:         *  This software is published under the terms of the Apache Software License
005:         *  version 1.1, a copy of which has been included  with this distribution in
006:         *  the LICENSE file.
007:         */
008:
009:        package net.sourceforge.chaperon.ant;
010:
011:        import org.apache.commons.logging.Log;
012:
013:        import org.apache.tools.ant.Project;
014:
015:        /**
016:         * The Ant wrapper class for Logger.
017:         *
018:         * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
019:         * @version CVS $Id: AntLog.java,v 1.3 2004/01/09 10:48:06 benedikta Exp $
020:         */
021:        public final class AntLog implements  Log {
022:            // underlying implementation to delegate to
023:            private final Project project;
024:            private boolean use_level = false;
025:            private int antMsgLevel = Project.MSG_ERR;
026:
027:            /**
028:             * Create a logger that delegates to specified logger.
029:             *
030:             * @param project the Ant logger to delegate to
031:             */
032:            public AntLog(Project project) {
033:                this .project = project;
034:            }
035:
036:            /**
037:             * Create a logger that delegates to specified logger.
038:             *
039:             * @param project the Ant logger to delegate to
040:             * @param antMsgLevel the massage level from ant
041:             */
042:            public AntLog(Project project, int antMsgLevel) {
043:                this .project = project;
044:                this .antMsgLevel = antMsgLevel;
045:                use_level = true;
046:            }
047:
048:            /**
049:             * <p>
050:             * Log a message with trace log level.
051:             * </p>
052:             *
053:             * @param message log this message
054:             */
055:            public void trace(Object message) {
056:                if ((use_level) && (antMsgLevel == Project.MSG_DEBUG))
057:                    project.log(message.toString());
058:
059:                project.log(message.toString(), Project.MSG_DEBUG);
060:            }
061:
062:            /**
063:             * <p>
064:             * Log an error with trace log level.
065:             * </p>
066:             *
067:             * @param message log this message
068:             * @param t log this cause
069:             */
070:            public void trace(Object message, Throwable t) {
071:                if ((use_level) && (antMsgLevel == Project.MSG_DEBUG))
072:                    project.log(message + ":" + toString(t));
073:
074:                project.log(message + ":" + toString(t), Project.MSG_DEBUG);
075:            }
076:
077:            /**
078:             * <p>
079:             * Is trace logging currently enabled?
080:             * </p>
081:             * 
082:             * <p>
083:             * Call this method to prevent having to perform expensive operations (for example,
084:             * <code>String</code> concatination) when the log level is more than trace.
085:             * </p>
086:             */
087:            public boolean isTraceEnabled() {
088:                if (use_level)
089:                    return antMsgLevel == Project.MSG_DEBUG;
090:
091:                return true;
092:            }
093:
094:            /**
095:             * <p>
096:             * Log a message with debug log level.
097:             * </p>
098:             *
099:             * @param message log this message
100:             */
101:            public void debug(Object message) {
102:                if ((use_level) && (antMsgLevel == Project.MSG_DEBUG))
103:                    project.log(message.toString());
104:
105:                project.log(message.toString(), Project.MSG_DEBUG);
106:            }
107:
108:            /**
109:             * <p>
110:             * Log an error with debug log level.
111:             * </p>
112:             *
113:             * @param message log this message
114:             * @param t log this cause
115:             */
116:            public void debug(Object message, Throwable t) {
117:                if ((use_level) && (antMsgLevel == Project.MSG_DEBUG))
118:                    project.log(message + ":" + toString(t));
119:
120:                project.log(message + ":" + toString(t), Project.MSG_DEBUG);
121:            }
122:
123:            /**
124:             * <p>
125:             * Is debug logging currently enabled?
126:             * </p>
127:             * 
128:             * <p>
129:             * Call this method to prevent having to perform expensive operations (for example,
130:             * <code>String</code> concatination) when the log level is more than debug.
131:             * </p>
132:             */
133:            public boolean isDebugEnabled() {
134:                if (use_level)
135:                    return antMsgLevel == Project.MSG_DEBUG;
136:
137:                return true;
138:            }
139:
140:            /**
141:             * <p>
142:             * Log a message with info log level.
143:             * </p>
144:             *
145:             * @param message log this message
146:             */
147:            public void info(Object message) {
148:                if ((use_level) && (antMsgLevel == Project.MSG_INFO))
149:                    project.log(message.toString());
150:
151:                project.log(message.toString(), Project.MSG_INFO);
152:            }
153:
154:            /**
155:             * <p>
156:             * Log an error with info log level.
157:             * </p>
158:             *
159:             * @param message log this message
160:             * @param t log this cause
161:             */
162:            public void info(Object message, Throwable t) {
163:                if ((use_level) && (antMsgLevel == Project.MSG_INFO))
164:                    project.log(message + ":" + toString(t));
165:
166:                project.log(message + ":" + toString(t), Project.MSG_INFO);
167:            }
168:
169:            /**
170:             * <p>
171:             * Is info logging currently enabled?
172:             * </p>
173:             * 
174:             * <p>
175:             * Call this method to prevent having to perform expensive operations (for example,
176:             * <code>String</code> concatination) when the log level is more than info.
177:             * </p>
178:             */
179:            public boolean isInfoEnabled() {
180:                if (use_level)
181:                    return antMsgLevel == Project.MSG_INFO;
182:
183:                return true;
184:            }
185:
186:            /**
187:             * <p>
188:             * Log a message with warn log level.
189:             * </p>
190:             *
191:             * @param message log this message
192:             */
193:            public void warn(Object message) {
194:                if ((use_level) && (antMsgLevel == Project.MSG_WARN))
195:                    project.log(message.toString());
196:
197:                project.log(message.toString(), Project.MSG_WARN);
198:            }
199:
200:            /**
201:             * <p>
202:             * Log an error with warn log level.
203:             * </p>
204:             *
205:             * @param message log this message
206:             * @param t log this cause
207:             */
208:            public void warn(Object message, Throwable t) {
209:                if ((use_level) && (antMsgLevel == Project.MSG_WARN))
210:                    project.log(message + ":" + toString(t));
211:
212:                project.log(message + ":" + toString(t), Project.MSG_WARN);
213:            }
214:
215:            /**
216:             * <p>
217:             * Is warning logging currently enabled?
218:             * </p>
219:             * 
220:             * <p>
221:             * Call this method to prevent having to perform expensive operations (for example,
222:             * <code>String</code> concatination) when the log level is more than warning.
223:             * </p>
224:             */
225:            public boolean isWarnEnabled() {
226:                if (use_level)
227:                    return antMsgLevel == Project.MSG_WARN;
228:
229:                return true;
230:            }
231:
232:            /**
233:             * <p>
234:             * Log a message with error log level.
235:             * </p>
236:             *
237:             * @param message log this message
238:             */
239:            public void error(Object message) {
240:                if ((use_level) && (antMsgLevel == Project.MSG_ERR))
241:                    project.log(message.toString());
242:
243:                project.log(message.toString(), Project.MSG_ERR);
244:            }
245:
246:            /**
247:             * <p>
248:             * Log an error with error log level.
249:             * </p>
250:             *
251:             * @param message log this message
252:             * @param t log this cause
253:             */
254:            public void error(Object message, Throwable t) {
255:                if ((use_level) && (antMsgLevel == Project.MSG_ERR))
256:                    project.log(message + ":" + toString(t));
257:
258:                project.log(message + ":" + toString(t), Project.MSG_ERR);
259:            }
260:
261:            /**
262:             * <p>
263:             * Is error logging currently enabled?
264:             * </p>
265:             * 
266:             * <p>
267:             * Call this method to prevent having to perform expensive operations (for example,
268:             * <code>String</code> concatination) when the log level is more than error.
269:             * </p>
270:             */
271:            public boolean isErrorEnabled() {
272:                if (use_level)
273:                    return antMsgLevel == Project.MSG_ERR;
274:
275:                return true;
276:            }
277:
278:            /**
279:             * <p>
280:             * Log a message with fatal log level.
281:             * </p>
282:             *
283:             * @param message log this message
284:             */
285:            public void fatal(Object message) {
286:                if ((use_level) && (antMsgLevel == Project.MSG_ERR))
287:                    project.log(message.toString());
288:
289:                project.log(message.toString(), Project.MSG_ERR);
290:            }
291:
292:            /**
293:             * <p>
294:             * Log an error with fatal log level.
295:             * </p>
296:             *
297:             * @param message log this message
298:             * @param t log this cause
299:             */
300:            public void fatal(Object message, Throwable t) {
301:                if ((use_level) && (antMsgLevel == Project.MSG_ERR))
302:                    project.log(message + ":" + toString(t));
303:
304:                project.log(message + ":" + toString(t), Project.MSG_ERR);
305:            }
306:
307:            /**
308:             * <p>
309:             * Is fatal logging currently enabled?
310:             * </p>
311:             * 
312:             * <p>
313:             * Call this method to prevent having to perform expensive operations (for example,
314:             * <code>String</code> concatination) when the log level is more than fatal.
315:             * </p>
316:             */
317:            public boolean isFatalEnabled() {
318:                if (use_level)
319:                    return antMsgLevel == Project.MSG_ERR;
320:
321:                return true;
322:            }
323:
324:            private String toString(Throwable t) {
325:                StringBuffer buffer = new StringBuffer();
326:                if (t != null) {
327:                    buffer.append(" <");
328:                    buffer.append(t.toString());
329:                    buffer.append(">");
330:
331:                    java.io.StringWriter sw = new java.io.StringWriter(1024);
332:                    java.io.PrintWriter pw = new java.io.PrintWriter(sw);
333:                    t.printStackTrace(pw);
334:                    pw.close();
335:                    buffer.append(sw.toString());
336:                }
337:
338:                return buffer.toString();
339:            }
340:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.