01: /*
02: This software is OSI Certified Open Source Software.
03: OSI Certified is a certification mark of the Open Source Initiative.
04:
05: The license (Mozilla version 1.0) can be read at the MMBase site.
06: See http://www.MMBase.org/license
07:
08: */
09: package org.mmbase.util.logging;
10:
11: import java.io.Writer;
12:
13: /**
14: * A Logger which writes everything logged to it to a given Writer. The Writer can e.g. be a {@link
15: * java.io.StringWriter} if you want to create one String.
16: *
17: * @author Michiel Meeuwissen
18: * @version $Id: WriterLogger.java,v 1.3 2005/09/12 23:23:47 michiel Exp $
19: * @since MMBase-1.8
20: */
21:
22: public class WriterLogger extends AbstractSimpleImpl {
23:
24: private Writer writer;
25:
26: public WriterLogger(Writer w) {
27: this (w, Level.INFO);
28: }
29:
30: public WriterLogger(Writer w, Level l) {
31: level = l.toInt();
32: writer = w;
33: }
34:
35: protected final void log(String s, Level level) {
36: try {
37: writer.write(s);
38: writer.write('\n');
39: } catch (java.io.IOException ioe) {
40: // should not happen
41: }
42: }
43: }
|