/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package logger;

import java.io.File;
import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import logger.myformatter.MyFormatter;

/**
 * nobody
 * 
 */
public class OhmLogger 
{
  private static Logger lg = null;

  public static Logger getLogger()
  {
    if (lg == null)
    {
      lg = Logger.getLogger("OhmLogger");
      initLogger();
    }
    return lg;
  }

  private static void initLogger()
  {
    try
    {
      String datei = System.getProperty("java.io.tmpdir") + File.separator + "log.txt";
      FileHandler fh = new FileHandler(datei);
      ConsoleHandler ch = new ConsoleHandler();
      lg.setUseParentHandlers(false);
      lg.addHandler(fh);
      ch.setFormatter(new MyFormatter());
      lg.addHandler(ch);
      lg.setLevel(Level.ALL);
    }
    catch (IOException ioex)
    {
      System.err.println(ioex);
    }
  }

  public OhmLogger()
  {

  }
}