Source Code Cross Referenced for Logger.java in  » Report » pentaho-report » org » pentaho » 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 » Report » pentaho report » org.pentaho.util.logging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved. 
003:         * This software was developed by Pentaho Corporation and is provided under the terms 
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
005:         * this file except in compliance with the license. If you need a copy of the license, 
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
011:         * the license for the specific language governing your rights and limitations.
012:         *
013:         * @created May 4, 2005 
014:         * @author James Dixon
015:         * 
016:         */
017:        package org.pentaho.util.logging;
018:
019:        import org.apache.commons.logging.Log;
020:        import org.apache.commons.logging.LogFactory;
021:        import org.pentaho.core.system.PentahoSystem;
022:        import org.pentaho.messages.Messages;
023:        import org.pentaho.util.IVersionHelper;
024:
025:        public class Logger {
026:
027:            private static int logLevel = ILogger.ERROR;
028:
029:            private static String MISC_LOG = "misc-"; //$NON-NLS-1$
030:
031:            private static Log logger;
032:
033:            private static String logName = "org.pentaho.util.logging.Logger"; //$NON-NLS-1$
034:
035:            static {
036:                logger = LogFactory.getLog(logName);
037:            }
038:
039:            public static String getLogLevelName(int localLogLevel) {
040:                switch (localLogLevel) {
041:                case ILogger.TRACE:
042:                    return "TRACE"; //$NON-NLS-1$
043:                case ILogger.DEBUG:
044:                    return "DEBUG"; //$NON-NLS-1$
045:                case ILogger.INFO:
046:                    return "INFO"; //$NON-NLS-1$
047:                case ILogger.WARN:
048:                    return "WARN"; //$NON-NLS-1$
049:                case ILogger.ERROR:
050:                    return "ERROR"; //$NON-NLS-1$
051:                case ILogger.FATAL:
052:                    return "FATAL"; //$NON-NLS-1$
053:                default:
054:                    return Messages.getString("Logger.CODE_LOG_UNKNOWN"); //$NON-NLS-1$
055:                }
056:            }
057:
058:            public static int getLogLevel(String localLogLevel) {
059:                if ("TRACE".equalsIgnoreCase(localLogLevel)) { //$NON-NLS-1$
060:                    return ILogger.TRACE;
061:                }
062:                if ("DEBUG".equalsIgnoreCase(localLogLevel)) { //$NON-NLS-1$
063:                    return ILogger.DEBUG;
064:                }
065:                if ("INFO".equalsIgnoreCase(localLogLevel)) { //$NON-NLS-1$
066:                    return ILogger.INFO;
067:                }
068:                if ("WARN".equalsIgnoreCase(localLogLevel)) { //$NON-NLS-1$
069:                    return ILogger.WARN;
070:                }
071:                if ("ERROR".equalsIgnoreCase(localLogLevel)) { //$NON-NLS-1$
072:                    return ILogger.ERROR;
073:                }
074:                if ("FATAL".equalsIgnoreCase(localLogLevel)) { //$NON-NLS-1$
075:                    return ILogger.FATAL;
076:                }
077:                return ILogger.ERROR;
078:            }
079:
080:            public static int getLogLevel() {
081:                return logLevel;
082:            }
083:
084:            public static void setLogLevel(int newLogLevel) {
085:                logLevel = newLogLevel;
086:            }
087:
088:            public static void trace(Object caller, String message) {
089:                String id = (caller == null) ? Messages
090:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
091:                if (logLevel <= ILogger.TRACE) {
092:                    logger.trace(MISC_LOG + id + ": " + message); //$NON-NLS-1$
093:                }
094:            }
095:
096:            public static void debug(Object caller, String message) {
097:                String id = (caller == null) ? Messages
098:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
099:                if (logLevel <= ILogger.DEBUG) {
100:                    logger.debug(MISC_LOG + id + ": " + message); //$NON-NLS-1$
101:                }
102:            }
103:
104:            public static void info(Object caller, String message) {
105:                String id = (caller == null) ? Messages
106:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
107:                if (logLevel <= ILogger.INFO) {
108:                    logger.info(MISC_LOG + id + ": " + message); //$NON-NLS-1$
109:                }
110:            }
111:
112:            public static void warn(Object caller, String message) {
113:                String id = (caller == null) ? Messages
114:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
115:                if (logLevel <= ILogger.WARN) {
116:                    logger.warn(MISC_LOG + id + ": " + message); //$NON-NLS-1$
117:                }
118:            }
119:
120:            public static void error(Object caller, String message) {
121:                String id = (caller == null) ? Messages
122:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
123:                if (logLevel <= ILogger.ERROR) {
124:                    logger.error(MISC_LOG + id + ": " + message); //$NON-NLS-1$
125:                }
126:            }
127:
128:            public static void fatal(Object caller, String message) {
129:                String id = (caller == null) ? Messages
130:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
131:                if (logLevel <= ILogger.FATAL) {
132:                    logger.fatal(MISC_LOG + id + ": " + message); //$NON-NLS-1$
133:                }
134:            }
135:
136:            public static void trace(Object caller, String message,
137:                    Throwable error) {
138:                String id = (caller == null) ? Messages
139:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
140:                if (logLevel <= ILogger.TRACE) {
141:                    logger.trace(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
142:                }
143:            }
144:
145:            public static void debug(Object caller, String message,
146:                    Throwable error) {
147:                String id = (caller == null) ? Messages
148:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
149:                if (logLevel <= ILogger.DEBUG) {
150:                    logger.debug(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
151:                }
152:            }
153:
154:            public static void info(Object caller, String message,
155:                    Throwable error) {
156:                String id = (caller == null) ? Messages
157:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
158:                if (logLevel <= ILogger.INFO) {
159:                    logger.info(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
160:                }
161:            }
162:
163:            public static void warn(Object caller, String message,
164:                    Throwable error) {
165:                String id = (caller == null) ? Messages
166:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
167:                if (logLevel <= ILogger.WARN) {
168:                    logger.warn(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
169:                }
170:            }
171:
172:            public static void error(Object caller, String message,
173:                    Throwable error) {
174:                String id = (caller == null) ? Messages
175:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
176:                if (logLevel <= ILogger.ERROR) {
177:                    logger.error(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
178:                }
179:            }
180:
181:            public static void fatal(Object caller, String message,
182:                    Throwable error) {
183:                String id = (caller == null) ? Messages
184:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller.getClass().getName(); //$NON-NLS-1$
185:                if (logLevel <= ILogger.FATAL) {
186:                    logger.fatal(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
187:                }
188:            }
189:
190:            public static void debug(String caller, String message) {
191:                String id = (caller == null) ? Messages
192:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
193:                if (logLevel <= ILogger.DEBUG) {
194:                    logger.debug(MISC_LOG + id + ": " + message); //$NON-NLS-1$
195:                }
196:            }
197:
198:            public static void info(String caller, String message) {
199:                String id = (caller == null) ? Messages
200:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
201:                if (logLevel <= ILogger.INFO) {
202:                    logger.info(MISC_LOG + id + ": " + message); //$NON-NLS-1$
203:                }
204:            }
205:
206:            public static void warn(String caller, String message) {
207:                String id = (caller == null) ? Messages
208:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
209:                if (logLevel <= ILogger.WARN) {
210:                    logger.warn(MISC_LOG + id + ": " + message); //$NON-NLS-1$
211:                }
212:            }
213:
214:            public static void error(String caller, String message) {
215:                String id = (caller == null) ? Messages
216:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
217:                if (logLevel <= ILogger.ERROR) {
218:                    logger.error(MISC_LOG + id + ": " + message); //$NON-NLS-1$
219:                }
220:            }
221:
222:            public static void fatal(String caller, String message) {
223:                String id = (caller == null) ? Messages
224:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
225:                if (logLevel <= ILogger.FATAL) {
226:                    logger.fatal(MISC_LOG + id + ": " + message); //$NON-NLS-1$
227:                }
228:            }
229:
230:            public static void debug(String caller, String message,
231:                    Throwable error) {
232:                String id = (caller == null) ? Messages
233:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
234:                if (logLevel <= ILogger.DEBUG) {
235:                    logger.debug(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
236:                }
237:            }
238:
239:            public static void info(String caller, String message,
240:                    Throwable error) {
241:                String id = (caller == null) ? Messages
242:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
243:                if (logLevel <= ILogger.INFO) {
244:                    logger.info(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
245:                }
246:            }
247:
248:            public static void warn(String caller, String message,
249:                    Throwable error) {
250:                String id = (caller == null) ? Messages
251:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
252:                if (logLevel <= ILogger.WARN) {
253:                    logger.warn(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
254:                }
255:            }
256:
257:            public static void error(String caller, String message,
258:                    Throwable error) {
259:                String id = (caller == null) ? Messages
260:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
261:                if (logLevel <= ILogger.ERROR) {
262:                    IVersionHelper versionHelper = PentahoSystem
263:                            .getVersionHelper(null);
264:                    logger
265:                            .error("Error: Pentaho " + versionHelper.getVersionInformation(Logger.class)); //$NON-NLS-1$
266:                    logger.error(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
267:                    logger.error("Error end:"); //$NON-NLS-1$ 
268:                }
269:            }
270:
271:            public static void fatal(String caller, String message,
272:                    Throwable error) {
273:                String id = (caller == null) ? Messages
274:                        .getString("Logger.DEBUG_LOG_UNKNOWN") : caller; //$NON-NLS-1$
275:                if (logLevel <= ILogger.FATAL) {
276:                    IVersionHelper versionHelper = PentahoSystem
277:                            .getVersionHelper(null);
278:                    logger
279:                            .error("Error: Pentaho " + versionHelper.getVersionInformation(Logger.class)); //$NON-NLS-1$
280:                    logger.fatal(MISC_LOG + id + ": " + message, error); //$NON-NLS-1$
281:                    logger.error("Error end:"); //$NON-NLS-1$ 
282:                }
283:            }
284:
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.