trunk/com/so/news/Debug.java
changeset 1 6fceb66e1ad7
parent 0 f907866f0e4b
child 2 1090e2141798
     1.1 --- a/trunk/com/so/news/Debug.java	Tue Jan 20 10:21:03 2009 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,95 +0,0 @@
     1.4 -/*
     1.5 - *   StarOffice News Server
     1.6 - *   see AUTHORS for the list of contributors
     1.7 - *
     1.8 - *   This program is free software: you can redistribute it and/or modify
     1.9 - *   it under the terms of the GNU General Public License as published by
    1.10 - *   the Free Software Foundation, either version 3 of the License, or
    1.11 - *   (at your option) any later version.
    1.12 - *
    1.13 - *   This program is distributed in the hope that it will be useful,
    1.14 - *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 - *   GNU General Public License for more details.
    1.17 - *
    1.18 - *   You should have received a copy of the GNU General Public License
    1.19 - *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 - */
    1.21 -
    1.22 -package com.so.news;
    1.23 -
    1.24 -import java.io.FileOutputStream;
    1.25 -import java.io.IOException;
    1.26 -import java.io.PrintStream;
    1.27 -import java.util.Date;
    1.28 -
    1.29 -/**
    1.30 - * Provides logging and debugging methods.
    1.31 - * @author Christian Lins
    1.32 - */
    1.33 -public class Debug
    1.34 -{
    1.35 -  private static Debug instance = null;
    1.36 -  
    1.37 -  /**
    1.38 -   * Returns the singelton instance of this class.
    1.39 -   */
    1.40 -  public static Debug getInstance()
    1.41 -  {
    1.42 -    if(instance == null)
    1.43 -      instance = new Debug();
    1.44 -    
    1.45 -    return instance;
    1.46 -  }
    1.47 -  
    1.48 -  private PrintStream out = System.err;
    1.49 -  
    1.50 -  /**
    1.51 -   * This class is a singelton class. The constructor is private to prevent
    1.52 -   * the creation of more than one instance.
    1.53 -   */
    1.54 -  private Debug()
    1.55 -  {
    1.56 -    try
    1.57 -    {
    1.58 -      String filename = Config.getInstance().get(Config.CONFIG_N3TPD_LOGFILE, "n3tpd.log");
    1.59 -      
    1.60 -      this.out = new PrintStream(new FileOutputStream(filename));
    1.61 -    }
    1.62 -    catch(IOException e)
    1.63 -    {
    1.64 -      e.printStackTrace();
    1.65 -    }
    1.66 -  }
    1.67 -  
    1.68 -  /**
    1.69 -   * Returns the debug output PrintStream. By default this is System.err.
    1.70 -   */
    1.71 -  public PrintStream getStream()
    1.72 -  {
    1.73 -    return out;
    1.74 -  }
    1.75 -  
    1.76 -  /**
    1.77 -   * Writes the given message to the debug output.
    1.78 -   * @param msg A String message or an object.
    1.79 -   */
    1.80 -  public void log(Object msg)
    1.81 -  {
    1.82 -    log(out, msg);
    1.83 -    log(System.out, msg);
    1.84 -  }
    1.85 -  
    1.86 -  /**
    1.87 -   * Writes the given debug message to the given PrintStream.
    1.88 -   * @param out
    1.89 -   * @param msg
    1.90 -   */
    1.91 -  public void log(PrintStream out, Object msg)
    1.92 -  {
    1.93 -    out.print(new Date().toString());
    1.94 -    out.print(": ");
    1.95 -    out.println(msg.toString());
    1.96 -    out.flush();
    1.97 -  }
    1.98 -}