Source Code Cross Referenced for CommonsLogger.java in  » GIS » GeoTools-2.4.1 » org » geotools » util » logging » 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 » GIS » GeoTools 2.4.1 » org.geotools.util.logging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2006-2007, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.util.logging;
017:
018:        import java.util.logging.Level;
019:        import org.apache.commons.logging.Log;
020:
021:        /**
022:         * An adapter that redirect all Java logging events to the Apache's
023:         * <A HREF="http://jakarta.apache.org/commons/logging/">Commons-logging</A> framework.
024:         *
025:         * @since 2.4
026:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/util/logging/CommonsLogger.java $
027:         * @version $Id: CommonsLogger.java 27891 2007-11-14 14:10:48Z desruisseaux $
028:         * @author Martin Desruisseaux
029:         * @author Saul Farber
030:         *
031:         * @see CommonsLoggerFactory
032:         * @see Logging
033:         */
034:        final class CommonsLogger extends LoggerAdapter {
035:            /**
036:             * The Apache logger to use.
037:             */
038:            final Log logger;
039:
040:            /**
041:             * Creates a new logger.
042:             *
043:             * @param name   The logger name.
044:             * @param logger The result of {@code LogFactory.getLog(name)}.
045:             */
046:            public CommonsLogger(final String name, final Log logger) {
047:                super (name);
048:                this .logger = logger;
049:            }
050:
051:            /**
052:             * Do nothing since Commons-Logging doesn't support programmatic change of logging level.
053:             */
054:            public void setLevel(Level level) {
055:            }
056:
057:            /**
058:             * Returns the level for this logger.
059:             */
060:            public Level getLevel() {
061:                if (logger.isTraceEnabled())
062:                    return Level.FINEST;
063:                if (logger.isDebugEnabled())
064:                    return Level.FINE;
065:                if (logger.isInfoEnabled())
066:                    return Level.CONFIG;
067:                if (logger.isWarnEnabled())
068:                    return Level.WARNING;
069:                if (logger.isErrorEnabled())
070:                    return Level.SEVERE;
071:                if (logger.isFatalEnabled())
072:                    return Level.SEVERE;
073:                return Level.OFF;
074:            }
075:
076:            /**
077:             * Returns {@code true} if the specified level is loggable.
078:             */
079:            public boolean isLoggable(final Level level) {
080:                final int n = level.intValue();
081:                switch (n / 100) {
082:                default: {
083:                    switch (n) { // Special cases (should not occur often).
084:                    case Integer.MIN_VALUE:
085:                        return true; // ALL
086:                    case Integer.MAX_VALUE:
087:                        return false; // OFF
088:                    default:
089:                        return n >= 0 && logger.isFatalEnabled();
090:                    }
091:                }
092:                case 10:
093:                    return logger.isErrorEnabled(); // SEVERE
094:                case 9:
095:                    return logger.isWarnEnabled(); // WARNING
096:                case 8: // INFO
097:                case 7:
098:                    return logger.isInfoEnabled(); // CONFIG
099:                case 6: // (not allocated)
100:                case 5:
101:                    return logger.isDebugEnabled(); // FINE
102:                case 4: // FINER
103:                case 3: // FINEST
104:                case 2: // (not allocated)
105:                case 1: // (not allocated)
106:                case 0:
107:                    return logger.isTraceEnabled(); // ALL
108:                }
109:            }
110:
111:            /**
112:             * Logs a record at the specified level.
113:             */
114:            public void log(final Level level, final String message,
115:                    final Throwable thrown) {
116:                final int n = level.intValue();
117:                switch (n / 100) {
118:                default: {
119:                    // MAX_VALUE is a special value for Level.OFF. Otherwise and
120:                    // if positive, log to fatal since we are greater than SEVERE.
121:                    if (n != Integer.MAX_VALUE || n >= 0) {
122:                        logger.fatal(message, thrown);
123:                    }
124:                    break;
125:                }
126:                case 10:
127:                    logger.error(message, thrown);
128:                    break; // SEVERE
129:                case 9:
130:                    logger.warn(message, thrown);
131:                    break; // WARNING
132:                case 8: // INFO
133:                case 7:
134:                    logger.info(message, thrown);
135:                    break; // CONFIG
136:                case 6: // (not allocated)
137:                case 5:
138:                    logger.debug(message, thrown);
139:                    break; // FINE
140:                case 4: // FINER
141:                case 3: // FINEST
142:                case 2: // (not allocated)
143:                case 1: // (not allocated)
144:                case 0:
145:                    logger.trace(message, thrown);
146:                    break; // ALL
147:                }
148:            }
149:
150:            public void severe(String message) {
151:                logger.error(message);
152:            }
153:
154:            public void warning(String message) {
155:                logger.warn(message);
156:            }
157:
158:            public void info(String message) {
159:                logger.info(message);
160:            }
161:
162:            public void config(String message) {
163:                logger.info(message);
164:            }
165:
166:            public void fine(String message) {
167:                logger.debug(message);
168:            }
169:
170:            public void finer(String message) {
171:                logger.debug(message);
172:            }
173:
174:            public void finest(String message) {
175:                logger.trace(message);
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.