001: package org.tanukisoftware.wrapper.test;
002:
003: /*
004: * Copyright (c) 1999, 2006 Tanuki Software Inc.
005: *
006: * Permission is hereby granted, free of charge, to any person
007: * obtaining a copy of the Java Service Wrapper and associated
008: * documentation files (the "Software"), to deal in the Software
009: * without restriction, including without limitation the rights
010: * to use, copy, modify, merge, publish, distribute, sub-license,
011: * and/or sell copies of the Software, and to permit persons to
012: * whom the Software is furnished to do so, subject to the
013: * following conditions:
014: *
015: * The above copyright notice and this permission notice shall be
016: * included in all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
020: * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
021: * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
022: * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
023: * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
024: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
025: * OTHER DEALINGS IN THE SOFTWARE.
026: *
027: *
028: * Portions of the Software have been derived from source code
029: * developed by Silver Egg Technology under the following license:
030: *
031: * Copyright (c) 2001 Silver Egg Technology
032: *
033: * Permission is hereby granted, free of charge, to any person
034: * obtaining a copy of this software and associated documentation
035: * files (the "Software"), to deal in the Software without
036: * restriction, including without limitation the rights to use,
037: * copy, modify, merge, publish, distribute, sub-license, and/or
038: * sell copies of the Software, and to permit persons to whom the
039: * Software is furnished to do so, subject to the following
040: * conditions:
041: *
042: * The above copyright notice and this permission notice shall be
043: * included in all copies or substantial portions of the Software.
044: */
045:
046: import org.tanukisoftware.wrapper.WrapperManager;
047:
048: /**
049: *
050: *
051: * @author Leif Mortenson <leif@tanukisoftware.com>
052: */
053: public class LogOutput {
054: private static void sleep() {
055: try {
056: Thread.sleep(2000);
057: } catch (InterruptedException e) {
058: }
059: }
060:
061: /*---------------------------------------------------------------
062: * Main Method
063: *-------------------------------------------------------------*/
064: public static void main(String[] args) {
065: System.out.println("Test the various log levels...");
066: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_DEBUG,
067: "Debug output");
068: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO,
069: "Info output");
070: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_STATUS,
071: "Status output");
072: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_WARN,
073: "Warn output");
074: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_ERROR,
075: "Error output");
076: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_FATAL,
077: "Fatal output");
078:
079: // Let things catch up as the timing of WrapperManager.log output and System.out
080: // output can not be guaranteed.
081: sleep();
082:
083: System.out.println("Put the logger through its paces...");
084: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO,
085: "Special C characters in %s %d % %%");
086: sleep();
087: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO, "");
088: sleep();
089:
090: String sa = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
091: StringBuffer sb = new StringBuffer();
092: for (int i = 0; i < 100; i++) {
093: sb.append(sa);
094: }
095: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO, sb
096: .toString());
097: sleep();
098:
099: sb = new StringBuffer();
100: for (int i = 0; i < 100; i++) {
101: sb.append(sa);
102: sb.append("\n");
103: }
104: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO, sb
105: .toString());
106: sleep();
107:
108: for (int i = 0; i < 100; i++) {
109: WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO,
110: sa);
111: }
112: }
113: }
|