01: /**
02: *
03: * Copyright (C) 2000-2004 Enterprise Distributed Technologies Ltd
04: *
05: * www.enterprisedt.com
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: * Bug fixes, suggestions and comments should be sent to bruce@enterprisedt.com
22: *
23: * Change Log:
24: *
25: * $Log: StandardOutputAppender.java,v $
26: * Revision 1.4 2006/10/12 12:38:58 bruceb
27: * synchronized methods
28: *
29: * Revision 1.3 2005/09/28 09:11:25 bruceb
30: * flush
31: *
32: * Revision 1.2 2004/08/16 21:08:08 bruceb
33: * made cvsids public
34: *
35: * Revision 1.1 2004/05/15 22:35:44 bruceb
36: * stdout appender
37: *
38: * Revision 1.1 2004/05/01 16:55:42 bruceb
39: * first cut
40: *
41: *
42: */package com.enterprisedt.util.debug;
43:
44: import java.io.PrintWriter;
45:
46: /**
47: * Appends log statements to standard output
48: *
49: * @author Bruce Blackshaw
50: * @version $Revision: 1.4 $
51: */
52: public class StandardOutputAppender implements Appender {
53:
54: /**
55: * Revision control id
56: */
57: public static String cvsId = "@(#)$Id: StandardOutputAppender.java,v 1.4 2006/10/12 12:38:58 bruceb Exp $";
58:
59: /**
60: * Destination
61: */
62: private PrintWriter log = new PrintWriter(System.out);
63:
64: /**
65: * Constructor
66: */
67: public StandardOutputAppender() {
68: }
69:
70: /**
71: * Log a message
72: *
73: * @param msg message to log
74: */
75: public synchronized void log(String msg) {
76: log.println(msg);
77: log.flush();
78: }
79:
80: /* (non-Javadoc)
81: * @see com.enterprisedt.util.debug.Appender#log(java.lang.Throwable)
82: */
83: public synchronized void log(Throwable t) {
84: t.printStackTrace(log);
85: log.flush();
86: }
87:
88: /* (non-Javadoc)
89: * @see com.enterprisedt.util.debug.Appender#close()
90: */
91: public synchronized void close() {
92: log.flush();
93: }
94: }
|