Source Code Cross Referenced for Logger.java in  » Database-JDBC-Connection-Pool » octopus » com » internetcds » 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 » Database JDBC Connection Pool » octopus » com.internetcds.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright 1998 CDS Networks, Inc., Medford Oregon
003:        //
004:        // All rights reserved.
005:        //
006:        // Redistribution and use in source and binary forms, with or without
007:        // modification, are permitted provided that the following conditions are met:
008:        // 1. Redistributions of source code must retain the above copyright
009:        //    notice, this list of conditions and the following disclaimer.
010:        // 2. Redistributions in binary form must reproduce the above copyright
011:        //    notice, this list of conditions and the following disclaimer in the
012:        //    documentation and/or other materials provided with the distribution.
013:        // 3. All advertising materials mentioning features or use of this software
014:        //    must display the following acknowledgement:
015:        //      This product includes software developed by CDS Networks, Inc.
016:        // 4. The name of CDS Networks, Inc.  may not be used to endorse or promote
017:        //    products derived from this software without specific prior
018:        //    written permission.
019:        //
020:        // THIS SOFTWARE IS PROVIDED BY CDS NETWORKS, INC. ``AS IS'' AND
021:        // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
022:        // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
023:        // ARE DISCLAIMED.  IN NO EVENT SHALL CDS NETWORKS, INC. BE LIABLE
024:        // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
025:        // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
026:        // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
027:        // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
028:        // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
029:        // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
030:        // SUCH DAMAGE.
031:        //
032:
033:        package com.internetcds.util;
034:
035:        import java.io.*;
036:
037:        /**
038:         * This class will log messages into a file.
039:         *
040:         * @version $Id: Logger.java,v 1.2 2007-10-19 13:23:55 sinisa Exp $
041:         * @author Craig Spannring
042:         */
043:        public class Logger {
044:            public static final String cvsVersion = "$Id: Logger.java,v 1.2 2007-10-19 13:23:55 sinisa Exp $";
045:
046:            private static String filename = "log.out";
047:            private static boolean active = false;
048:            private static PrintStream out = null;
049:
050:            /**
051:             * Initialize the logger facility.
052:             * <p>
053:             * If the log facility hasn't been initialized yet this routine will 
054:             * open the log file.
055:             * <p>
056:             * The routine must be called before any logging takes place.
057:             * All of the functions in this class that log messages should
058:             * call this routine.  It doesn't hurt anything if this is called
059:             * multiple times.
060:             */
061:            synchronized private static void init() throws IOException {
062:                // check to see if the file is already open
063:                if (out == null) {
064:                    // open the log file
065:                    out = new PrintStream(new FileOutputStream(filename));
066:                }
067:            }
068:
069:            /**
070:             * Turn the logging on or off.
071:             * <p>
072:             * The first time logging is turned on it will create the log file.
073:             *
074:             * @param value   when value is true it will turn the logging on, 
075:             *                if it is false it will turn the logging off.
076:             */
077:            synchronized public static void setActive(boolean value)
078:                    throws IOException {
079:                init();
080:                active = value;
081:            }
082:
083:            /**
084:             * Is logging turned on?
085:             */
086:            public static boolean isActive() {
087:                return active;
088:            }
089:
090:            /**
091:             * set the name of the log file.
092:             * <p>
093:             * This method allows you to set the name of the log file.
094:             * <B>Note-</B> Once the log file is open you can not change the 
095:             * name.
096:             *
097:             * @param value  name of the log file.
098:             */
099:            public synchronized static void setFilename(String value) {
100:                filename = value;
101:            }
102:
103:            /**
104:             * return the name of the log file.
105:             */
106:            public static String getFilename() {
107:                return filename;
108:            }
109:
110:            /**
111:             * Print a string into the log file if and only if logging is active
112:             */
113:            synchronized public static void print(String msg)
114:                    throws IOException {
115:                if (active) {
116:                    init();
117:                    out.print(msg);
118:                }
119:            }
120:
121:            /**
122:             * Print a string into the log file if and only if logging is active
123:             */
124:            synchronized public static void println(String msg)
125:                    throws IOException {
126:                if (active) {
127:                    init();
128:                    out.println(msg);
129:                }
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.