KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > util > LogStream


1 /* jcifs smb client library in Java
2  * Copyright (C) 2004 "Michael B. Allen" <jcifs at samba dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * 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 JavaDoc;
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 JavaDoc {
32
33     private static LogStream inst;
34
35     public static int level = 1;
36
37     public LogStream( PrintStream JavaDoc stream ) {
38         super( stream );
39     }
40
41     public static void setLevel( int level ) {
42         LogStream.level = level;
43     }
44     /**
45      * This must be called before <tt>getInstance</tt> is called or
46      * it will have no effect.
47      */

48     public static void setInstance( PrintStream JavaDoc stream ) {
49         inst = new LogStream( stream );
50     }
51     public static LogStream getInstance() {
52         if( inst == null ) {
53             setInstance( System.err );
54         }
55         return inst;
56     }
57 }
58
59
Popular Tags