package net.java_school.util;

import java.io.*;
import java.util.Date;

public class Log {
  
  public String dbgFile = "D:\\jdbc\\error.txt"; // À©µµ¿ì  °è¿­
  //public String dbgFile = "/jdbc/error.dbg"; // À¯´Ð½º °è¿­
  FileWriter fw = null;
  
  public Log() {
    super();
    try {
      fw = new FileWriter( dbgFile, true );
    } catch ( IOException e ){}
  }

  public void close() {
    try {
      fw.close();
    } catch ( IOException e ){}
  }

  public void close( FileWriter fw ) {
    try {
      fw.close();
    } catch ( IOException e ){}
  }

  public void debug( String msg ) {
    try {
      fw.write( "-------------------------------------------------\r\n" );
      fw.write( new java.util.Date()+ " : " );
      fw.write( msg + " \r\n" );
      fw.write( "-------------------------------------------------\r\n" );
      fw.flush();
    } catch ( IOException e ) {
      System.err.println( "IOException.......!!" );
    }
  }

  public static void out( String msg ) {
    System.out.println( new Date() + ": " + msg );
  }

  public static void err( String msg ) {
    System.out.println( new Date() + ": " + msg );
  }

  public static void err( Throwable e, String msg ) {
    System.err.println( new Date() + ": " + msg );
    e.printStackTrace( System.out );
  }
}
