Source Code Cross Referenced for Log.java in  » IDE-Eclipse » ui » org » eclipse » ui » internal » intro » universal » util » 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 » IDE Eclipse » ui » org.eclipse.ui.internal.intro.universal.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.intro.universal.util;
011:
012:        import org.eclipse.core.runtime.ILog;
013:        import org.eclipse.core.runtime.IStatus;
014:        import org.eclipse.core.runtime.MultiStatus;
015:        import org.eclipse.core.runtime.Platform;
016:        import org.eclipse.core.runtime.Status;
017:        import org.eclipse.ui.internal.intro.universal.IUniversalIntroConstants;
018:        import org.eclipse.ui.internal.intro.universal.UniversalIntroPlugin;
019:
020:        /**
021:         * Utility class for logging, based on Platform logging classes. The log
022:         * listerner used is the base one supplied by the platform. Error messages are
023:         * always logged. Warning messages are only logged when the plugin is in debug
024:         * mode. Info messages are only logged when the /trace/logInfo debug option is
025:         * set to true. Performance reports are only logged when /trace/performance is
026:         * set to true.
027:         * 
028:         */
029:        public class Log implements  IUniversalIntroConstants {
030:
031:            /**
032:             * This MUST be set to <b>false </b> in production. <br>
033:             * Used to compile out developement debug messages. <br>
034:             * Compiler compiles out code warpped wit this flag as an optimization.
035:             */
036:            public static final boolean DEBUG = false;
037:
038:            // Use these flags to filter out code that may be a performance hit.
039:            // Flag that controls logging of warning message
040:            public static boolean logWarning = false;
041:            // Flag that controls logging of information messages
042:            public static boolean logInfo = false;
043:            // Flag that controls logging of performance messages
044:            public static boolean logPerformance = false;
045:
046:            private final static ILog pluginLog = UniversalIntroPlugin
047:                    .getDefault().getLog();
048:
049:            static {
050:                // init debug options based on settings defined in ".options" file. If
051:                // the plugin is not in debug mode, no point setting debug options.
052:                if (UniversalIntroPlugin.getDefault().isDebugging()) {
053:                    logWarning = true;
054:                    logInfo = getDebugOption("/trace/logInfo"); //$NON-NLS-1$
055:                    logPerformance = getDebugOption("/trace/logPerformance"); //$NON-NLS-1$
056:                }
057:
058:            }
059:
060:            private static boolean getDebugOption(String option) {
061:                return "true".equalsIgnoreCase(//$NON-NLS-1$
062:                        Platform.getDebugOption(PLUGIN_ID + option));
063:            }
064:
065:            /**
066:             * Log an Error message with an exception. Note that the message should
067:             * already be localized to proper local. Errors are always logged.
068:             */
069:            public static synchronized void error(String message, Throwable ex) {
070:                if (message == null)
071:                    message = ""; //$NON-NLS-1$
072:                Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID,
073:                        IStatus.OK, message, ex);
074:                pluginLog.log(errorStatus);
075:            }
076:
077:            /**
078:             * Log an Information message. Note that the message should already be
079:             * localized to proper local. Info messages are only logged when the
080:             * /trace/logInfo debug option is true.
081:             */
082:            public static synchronized void info(String message) {
083:                if (!logInfo)
084:                    // logging of info messages is not enabled.
085:                    return;
086:
087:                if (message == null)
088:                    message = ""; //$NON-NLS-1$
089:                Status infoStatus = new Status(IStatus.INFO, PLUGIN_ID,
090:                        IStatus.OK, message, null);
091:                pluginLog.log(infoStatus);
092:            }
093:
094:            /**
095:             * Log an Information message. Note that the message should already be
096:             * localized to proper local. These messages are always logged. They are not
097:             * controlled by any debug flags. Logging of these messages can be
098:             * controlled by the public flags in this class.
099:             */
100:            public static synchronized void forcedInfo(String message) {
101:                if (message == null)
102:                    message = ""; //$NON-NLS-1$
103:                Status infoStatus = new Status(IStatus.INFO, PLUGIN_ID,
104:                        IStatus.OK, message, null);
105:                pluginLog.log(infoStatus);
106:            }
107:
108:            /**
109:             * Log a Warning message. Note that the message should already be localized
110:             * to proper local. Warning messages are only logged when the plugin is in
111:             * debug mode.
112:             */
113:            public static synchronized void warning(String message) {
114:                if (!logWarning)
115:                    // no warning messages (ie: plugin is not in debug mode). Default is
116:                    // to not log warning messages.
117:                    return;
118:
119:                if (message == null)
120:                    message = ""; //$NON-NLS-1$
121:                Status warningStatus = new Status(IStatus.WARNING, PLUGIN_ID,
122:                        IStatus.OK, message, null);
123:                pluginLog.log(warningStatus);
124:            }
125:
126:            /**
127:             * Log a development debug message. Debug messages are compiled out.
128:             */
129:            public static synchronized void debugMessage(String className,
130:                    String message) {
131:                if (DEBUG) {
132:                    MultiStatus debugStatus = new MultiStatus(PLUGIN_ID,
133:                            IStatus.OK, className, null);
134:                    Status infoStatus = new Status(IStatus.OK, PLUGIN_ID,
135:                            IStatus.OK, message, null);
136:                    debugStatus.add(infoStatus);
137:                    pluginLog.log(debugStatus);
138:                }
139:            }
140:        }
ww___w_._j___ava2s.___co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.