01: /* jcifs smb client library in Java
02: * Copyright (C) 2004 "Michael B. Allen" <jcifs at samba dot org>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package jcifs.util;
20:
21: import java.io.PrintStream;
22:
23: /**
24: 0 - nothing
25: 1 - critical [default]
26: 2 - basic info can be logged under load
27: 3 - almost everything
28: N - debugging
29: */
30:
31: public class LogStream extends PrintStream {
32:
33: private static LogStream inst;
34:
35: public static int level = 1;
36:
37: public LogStream(PrintStream stream) {
38: super (stream);
39: }
40:
41: public static void setLevel(int level) {
42: LogStream.level = level;
43: }
44:
45: /**
46: * This must be called before <tt>getInstance</tt> is called or
47: * it will have no effect.
48: */
49: public static void setInstance(PrintStream stream) {
50: inst = new LogStream(stream);
51: }
52:
53: public static LogStream getInstance() {
54: if (inst == null) {
55: setInstance(System.err);
56: }
57: return inst;
58: }
59: }
|