Source Code Cross Referenced for LogUtils.java in  » ESB » celtix-1.0 » org » objectweb » celtix » common » 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 » ESB » celtix 1.0 » org.objectweb.celtix.common.logging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.common.logging;
002:
003:        import java.text.MessageFormat;
004:        import java.util.ResourceBundle;
005:        import java.util.logging.Level;
006:        import java.util.logging.Logger;
007:
008:        import org.objectweb.celtix.common.i18n.BundleUtils;
009:
010:        /**
011:         * A container for static utility methods related to logging.
012:         */
013:        public final class LogUtils {
014:
015:            private static final Object[] NO_PARAMETERS = new Object[0];
016:
017:            /**
018:             * Prevents instantiation.
019:             */
020:            private LogUtils() {
021:            }
022:
023:            /**
024:             * Get a Logger with an associated resource bundle.
025:             *
026:             * @param cls the Class to contain the Logger
027:             * @return an appropriate Logger 
028:             */
029:            public static Logger getL7dLogger(Class cls) {
030:                return Logger.getLogger(cls.getName(), BundleUtils
031:                        .getBundleName(cls));
032:            }
033:
034:            /**
035:             * Allows both parameter substitution and a typed Throwable to be logged.
036:             *
037:             * @param logger the Logger the log to
038:             * @param level the severity level
039:             * @param message the log message
040:             * @param throwable the Throwable to log
041:             * @param parameter the parameter to substitute into message
042:             */
043:            public static void log(Logger logger, Level level, String message,
044:                    Throwable throwable, Object parameter) {
045:                if (logger.isLoggable(level)) {
046:                    final String formattedMessage = MessageFormat.format(
047:                            localize(logger, message), parameter);
048:                    logger.log(level, formattedMessage, throwable);
049:                }
050:            }
051:
052:            /**
053:             * Allows both parameter substitution and a typed Throwable to be logged.
054:             *
055:             * @param logger the Logger the log to
056:             * @param level the severity level
057:             * @param message the log message
058:             * @param throwable the Throwable to log
059:             * @param parameters the parameters to substitute into message
060:             */
061:            public static void log(Logger logger, Level level, String message,
062:                    Throwable throwable, Object... parameters) {
063:                if (logger.isLoggable(level)) {
064:                    final String formattedMessage = MessageFormat.format(
065:                            localize(logger, message), parameters);
066:                    logger.log(level, formattedMessage, throwable);
067:                }
068:            }
069:
070:            /**
071:             * Checks log level and logs
072:             *
073:             * @param logger the Logger the log to
074:             * @param level the severity level
075:             * @param message the log message
076:             */
077:            public static void log(Logger logger, Level level, String message) {
078:                if (logger.isLoggable(level)) {
079:                    final String formattedMessage = MessageFormat.format(
080:                            localize(logger, message), NO_PARAMETERS);
081:                    logger.log(level, formattedMessage);
082:                }
083:
084:            }
085:
086:            /**
087:             * Checks log level and logs
088:             *
089:             * @param logger the Logger the log to
090:             * @param level the severity level
091:             * @param message the log message
092:             * @param parameters the parameters to substitute into message
093:             */
094:            public static void log(Logger logger, Level level, String message,
095:                    Object[] parameters) {
096:                if (logger.isLoggable(level)) {
097:                    final String formattedMessage = MessageFormat.format(
098:                            localize(logger, message), parameters);
099:                    logger.log(level, formattedMessage);
100:                }
101:
102:            }
103:
104:            /**
105:             * Retreive localized message retreived from a logger's resource
106:             * bundle.
107:             *
108:             * @param logger the Logger
109:             * @param message the message to be localized
110:             */
111:            private static String localize(Logger logger, String message) {
112:                ResourceBundle bundle = logger.getResourceBundle();
113:                return bundle != null ? bundle.getString(message) : message;
114:            }
115:
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.