Source Code Cross Referenced for Trace.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » common » log » 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 » Database JDBC Connection Pool » sequoia 2.10.9 » org.continuent.sequoia.common.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
004:         * Science And Control (INRIA).
005:         * Contact: sequoia@continuent.org
006:         * 
007:         * Licensed under the Apache License, Version 2.0 (the "License");
008:         * you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at
010:         * 
011:         * http://www.apache.org/licenses/LICENSE-2.0
012:         * 
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License. 
018:         *
019:         * Initial developer(s): Emmanuel Cecchet.
020:         * Contributor(s): __________________.
021:         */package org.continuent.sequoia.common.log;
022:
023:        import org.apache.log4j.Level;
024:        import org.apache.log4j.Logger;
025:
026:        /**
027:         * This a wrapper to the log4j logging system. We provide additional features to
028:         * statically remove tracing.
029:         * 
030:         * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
031:         * @version 1.0
032:         */
033:        public class Trace {
034:            /** Log4j logger instance. */
035:            private Logger log4jLogger;
036:
037:            /**
038:             * Creates a new <code>Trace</code> object from a given log4j
039:             * <code>Logger</code>.
040:             * 
041:             * @param log4jLogger the log4j <code>Logger</code>
042:             */
043:            protected Trace(Logger log4jLogger) {
044:                this .log4jLogger = log4jLogger;
045:            }
046:
047:            /**
048:             * Retrieves a logger by its name.
049:             * 
050:             * @param name logger name
051:             * @return trace a <code>Trace</code> instance
052:             */
053:            public static Trace getLogger(String name) {
054:                return LogManager.getLogger(name);
055:            }
056:
057:            /**
058:             * Logs a message object with the <code>DEBUG</code> <code>Level</code>.
059:             * 
060:             * @param message the message object to log
061:             */
062:            public void debug(Object message) {
063:                log4jLogger.debug(message);
064:            }
065:
066:            /**
067:             * Logs a message object with the <code>DEBUG</code> <code>Level</code>
068:             * including the stack trace of the {@link Throwable}<code>error</code>
069:             * passed as parameter.
070:             * 
071:             * @param message the message object to log
072:             * @param error the exception to log, including its stack trace
073:             */
074:            public void debug(Object message, Throwable error) {
075:                log4jLogger.debug(message, error);
076:            }
077:
078:            /**
079:             * Logs a message object with the <code>ERROR</code> <code>Level</code>.
080:             * 
081:             * @param message the message object to log
082:             */
083:            public void error(Object message) {
084:                log4jLogger.error(message);
085:            }
086:
087:            /**
088:             * Logs a message object with the <code>ERROR</code> <code>Level</code>
089:             * including the stack trace of the {@link Throwable}<code>error</code>
090:             * passed as parameter.
091:             * 
092:             * @param message the message object to log.
093:             * @param error the exception to log, including its stack trace.
094:             */
095:            public void error(Object message, Throwable error) {
096:                log4jLogger.error(message, error);
097:            }
098:
099:            /**
100:             * Logs a message object with the <code>FATAL</code> <code>Level</code>.
101:             * 
102:             * @param message the message object to log.
103:             */
104:            public void fatal(Object message) {
105:                log4jLogger.fatal(message);
106:            }
107:
108:            /**
109:             * Logs a message object with the <code>FATAL</code> <code>Level</code>
110:             * including the stack trace of the {@link Throwable}<code>error</code>
111:             * passed as parameter.
112:             * 
113:             * @param message the message object to log.
114:             * @param error the exception to log, including its stack trace.
115:             */
116:            public void fatal(Object message, Throwable error) {
117:                log4jLogger.fatal(message, error);
118:            }
119:
120:            /**
121:             * Logs a message object with the <code>INFO</code> <code>Level</code>.
122:             * 
123:             * @param message the message object to log.
124:             */
125:            public void info(Object message) {
126:                log4jLogger.info(message);
127:            }
128:
129:            /**
130:             * Logs a message object with the <code>INFO</code> <code>Level</code>
131:             * including the stack trace of the {@link Throwable}<code>error</code>
132:             * passed as parameter.
133:             * 
134:             * @param message the message object to log.
135:             * @param error the exception to log, including its stack trace.
136:             */
137:            public void info(Object message, Throwable error) {
138:                log4jLogger.info(message, error);
139:            }
140:
141:            /**
142:             * Logs a message object with the <code>WARN</code> <code>Level</code>.
143:             * 
144:             * @param message the message object to log.
145:             */
146:            public void warn(Object message) {
147:                log4jLogger.warn(message);
148:            }
149:
150:            /**
151:             * Logs a message object with the <code>WARN</code> <code>Level</code>
152:             * including the stack trace of the {@link Throwable}<code>error</code>
153:             * passed as parameter.
154:             * 
155:             * @param message the message object to log.
156:             * @param error the exception to log, including its stack trace.
157:             */
158:            public void warn(Object message, Throwable error) {
159:                log4jLogger.warn(message, error);
160:            }
161:
162:            /**
163:             * Checks whether this category is enabled for the
164:             * <code>DEBUG</code> <code>Level</code>.
165:             * <p>
166:             * This function is intended to lessen the computational cost of disabled log
167:             * debug statements.
168:             * <p>
169:             * For some <code>cat</code> Category object, when you write,
170:             * 
171:             * <pre>
172:             *  cat.debug("This is entry number: " + i );
173:             * </pre>
174:             * 
175:             * <p>
176:             * You incur the cost constructing the message, concatenatiion in this case,
177:             * regardless of whether the message is logged or not.
178:             * <p>
179:             * If you are worried about speed, then you should write
180:             * 
181:             * <pre>
182:             *  if(cat.isDebugEnabled()) { cat.debug("This is entry number: " + i ); }
183:             * </pre>
184:             * 
185:             * <p>
186:             * This way you will not incur the cost of parameter construction if debugging
187:             * is disabled for <code>cat</code>. On the other hand, if the
188:             * <code>cat</code> is debug enabled, you will incur the cost of evaluating
189:             * whether the category is debug enabled twice. Once in
190:             * <code>isDebugEnabled</code> and once in the <code>debug</code>. This
191:             * is an insignificant overhead since evaluating a category takes about 1%% of
192:             * the time it takes to actually log.
193:             * 
194:             * @return <code>true</code> if this category is debug enabled,
195:             *         <code>false</code> otherwise.
196:             */
197:            public boolean isDebugEnabled() {
198:                return log4jLogger.isDebugEnabled();
199:            }
200:
201:            /**
202:             * Checks whether this category is enabled for the <code>INFO</code>
203:             * <code>Level</code>.
204:             * 
205:             * @return <code>true</code> if this category is enabled for
206:             *         <code>Level</code> <code>INFO</code>, <code>false</code>
207:             *         otherwise.
208:             * @see #isDebugEnabled()
209:             */
210:            public boolean isInfoEnabled() {
211:                return log4jLogger.isInfoEnabled();
212:            }
213:
214:            /**
215:             * Checks whether this category is enabled for the <code>WARN</code> 
216:             * <code>Level</code>.
217:             * 
218:             * @return <code>true</code> if this category is enabled for
219:             *         <code>WARN</code> <code>Level</code>, <code>false</code>
220:             *         otherwise.
221:             * @see #isDebugEnabled()
222:             */
223:            public boolean isWarnEnabled() {
224:                return log4jLogger.isEnabledFor(Level.WARN);
225:            }
226:
227:            /**
228:             * Checks whether this category is enabled for the <code>ERROR</code>
229:             * <code>Level</code>.
230:             * 
231:             * @return <code>true</code> if this category is enabled for
232:             *         <code>ERROR</code> <code>Level</code>, <code>false</code>
233:             *         otherwise.
234:             * @see #isDebugEnabled()
235:             */
236:            public boolean isErrorEnabled() {
237:                return log4jLogger.isEnabledFor(Level.ERROR);
238:            }
239:
240:            /**
241:             * Checks whether this category is enabled for the <code>FATAL</code> 
242:             * <code>Level</code>.
243:             * 
244:             * @return <code>true</code> if this category is enabled for
245:             *         <code>FATAL</code> <code>Level</code>, <code>false</code>
246:             *         otherwise.
247:             * @see #isDebugEnabled()
248:             */
249:            public boolean isFatalEnabled() {
250:                return log4jLogger.isEnabledFor(Level.FATAL);
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.