/*
 * Log.java
 *
 * Created on October 11, 2000, 1:24 PM
 */

package ovt.util;

import java.io.*;

/**
 *
 * @author  ko
 * @version 
 */
public class Log extends Object {
    protected static PrintStream out = System.err;
    // 0 - no debug
    // 1 - some essential things
    protected static int debugLevel = 0;

    /** Creates new Log */
    public Log() {
    }
    
    public static void setOut(PrintStream output) {
        out = output;
    }
    
    public static void setDebugLevel(int level) {
        debugLevel = level;
    }
    
    public static int getDebugLevel() {
        return debugLevel;
    }
    
    /** Log the string with the debug level */
    public static void log(String str, int debug) {
        if (debug<=debugLevel) {
            out.println(" " + str);
        }
    }

    public static synchronized void log(String str) {
        log(str, 1);
    }
    
    /** Log the error string with the debug level */
    public static void err(String str, int debug) {
        if (debug<=debugLevel) {
            out.println(" " + str);
        }
    }
}