Source Code Cross Referenced for BasicLogFormatter.java in  » HTML-Parser » jericho-html » au » id » jericho » lib » html » 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 » HTML Parser » jericho html » au.id.jericho.lib.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Jericho HTML Parser - Java based library for analysing and manipulating HTML
002:        // Version 2.5
003:        // Copyright (C) 2007 Martin Jericho
004:        // http://jerichohtml.sourceforge.net/
005:        //
006:        // This library is free software; you can redistribute it and/or
007:        // modify it under the terms of either one of the following licences:
008:        //
009:        // 1. The Eclipse Public License (EPL) version 1.0,
010:        // included in this distribution in the file licence-epl-1.0.html
011:        // or available at http://www.eclipse.org/legal/epl-v10.html
012:        //
013:        // 2. The GNU Lesser General Public License (LGPL) version 2.1 or later,
014:        // included in this distribution in the file licence-lgpl-2.1.txt
015:        // or available at http://www.gnu.org/licenses/lgpl.txt
016:        //
017:        // This library is distributed on an "AS IS" basis,
018:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
019:        // See the individual licence texts for more details.
020:
021:        package au.id.jericho.lib.html;
022:
023:        import java.util.logging.*;
024:
025:        /**
026:         * Provides basic formatting for log messages.
027:         * <p>
028:         * This class extends the <code>java.util.logging.Formatter</code> class, allowing it to be specified as a formatter for the <code>java.util.logging</code> system.
029:         * <p>
030:         * The static {@link #format(String level, String message, String loggerName)} method provides a means of using the same formatting
031:         * outside of the <code>java.util.logging</code> framework.  See the documentation of this method for more details.
032:         */
033:        public class BasicLogFormatter extends Formatter {
034:            /**
035:             * Determines whether the <a href="Logger.html#LoggingLevel">logging level</a> is included in the output.
036:             * <p>
037:             * The default value is <code>true</code>.
038:             * <p>
039:             * As this is a static property, changing the value will affect all <code>BasicLogFormatter</code> instances, as well as the behaviour of the
040:             * static {@link #format(String level, String message, String loggerName)} method.
041:             */
042:            public static boolean OutputLevel = true;
043:
044:            /**
045:             * Determines whether the logger name is included in the output.
046:             * <p>
047:             * The default value is <code>false</code>.
048:             * <p>
049:             * The logger name used for all automatically created {@link Logger} instances is "<code>net.htmlparser.jericho</code>".
050:             * <p>
051:             * As this is a static property, changing the value will affect all <code>BasicLogFormatter</code> instances, as well as the behaviour of the
052:             * static {@link #format(String level, String message, String loggerName)} method.
053:             */
054:            public static boolean OutputName = false;
055:
056:            static final Formatter INSTANCE = new BasicLogFormatter();
057:
058:            /**
059:             * Returns a formatted string representing the log entry information contained in the specified <code>java.util.logging.LogRecord</code>.
060:             * <p>
061:             * This method is not called directly, but is used by the <code>java.util.logging</code> framework when this class is specified
062:             * as a formatter in the <code>logging.properties</code> file.
063:             * <p>
064:             * See the documentation of the parent <code>java.util.logging.Formatter</code> class in the Java SDK for more details.
065:             *
066:             * @param logRecord  a <code>java.util.logging.LogRecord</code> object containing all of the log entry information.
067:             * @return a formatted string representing the log entry information contained in the specified <code>java.util.logging.LogRecord</code>.
068:             */
069:            public String format(final LogRecord logRecord) {
070:                return format(logRecord.getLevel().getName(), logRecord
071:                        .getMessage(), logRecord.getLoggerName());
072:            }
073:
074:            /**
075:             * Returns a formatted string representing the specified log entry information.
076:             * <p>
077:             * This method is used by the {@link WriterLogger} class to format its output.
078:             * <p>
079:             * The static properties {@link #OutputLevel} and {@link #OutputName} affect what information is included in the output.
080:             * <p>
081:             * The {@link Config#NewLine} static property determines the character sequence used for line breaks.
082:             * <p>
083:             * A line of output typically looks like this:
084:             * <blockquote class="SmallVerticalMargin"><code>INFO: this is the log message</code></blockquote>
085:             * or if the {@link #OutputName} property is set to <code>true</code>, the output would look similar to this:
086:             * <blockquote class="SmallVerticalMargin"><code>INFO: [net.htmlparser.jericho] this is the log message</code></blockquote>
087:             *
088:             * @param level  a string representing the <a href="Logger.html#LoggingLevel">logging level</a> of the log entry.
089:             * @param message  the log message.
090:             * @param loggerName  the name of the logger.
091:             * @return a formatted string representing the specified log entry information.
092:             */
093:            public static String format(final String level,
094:                    final String message, final String loggerName) {
095:                final StringBuffer sb = new StringBuffer(message.length() + 40);
096:                if (OutputLevel)
097:                    sb.append(level).append(": ");
098:                if (OutputName && loggerName != null)
099:                    sb.append('[').append(loggerName).append("] ");
100:                sb.append(message);
101:                sb.append(Config.NewLine);
102:                return sb.toString();
103:            }
104:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.