/**
 * Copyright Acelet Corp. 2000. All rights reserved
 * 
 * License agreement begins >>>>>>>>>> <br>
 * This program (com.acelet.opensource.logging.Alog) ("Software") is an 
 * open source software. <p>
 * 
 * LICENSE GRANT. The Software is owned by Acelet Corporation ("Acelet"). 
 * The Software is licensed to you ("Licensee"). You are granted a 
 * non-exclusive right to use, modify, distribute the Software for either
 * commercial or non-commercial use for free, as long as: <br>
 * 1. this copyright paragraph remains with this file. <br>
 * 2. this source code (this file) must be included with distributed 
 * binary code.<br>
 * 
 * NO WARRANTY. This comes with absolutely no warranty. <p>
 * 
 * <<<<<<<<<< License agreement ends <p><p>
 * 
 * The purpose of releasing this open source program is to prevent vendor 
 * lock in. <p>
 * 
 * You can code your program using this class to indirectly use Acelet 
 * SuperLogging (com.acelet.logging). If later you want to swith to other
 * logging package, you do not need to modify your program. All you have
 * to do is: <p>
 * 1. modify this file to redirect to other logging packages. <br>
 * 2. replace existing com.acelet.opensource.Alog with your modified one. <br>
 * 3. you may have to reboot your EJB server to make the changes effect.<br>
 * <p>
 *
 * This program is just a wrapper. For detail information about the methods
 * see documents of underline package, such as com.acelet.logging.Logging.
 *
 * <p>
 * Visit http://www.ACElet.com for more information. 
 * <p>
 *
 * This file is a modified for using JDK logging as an EXAMPLE.
 * <br>
 * You can use Redress tool to keep your whereabouts information
 * always correct. See http://www.ACElet.com/freeware for detail.
 * <p>
 * Please see http://www/ACElet.com/opensource if you want to see the
 * original version.
 *
**/

package com.acelet.opensource.logging;

import java.util.logging.*;

public final class Alog {
  /**
   * Log level value: something will prevent normal program execution.
   */
  public static int SEVERE = 1000;

  /**
   * Log level value: something has potential problems.
   */
  public static int WARNING = 900;

  /**
   * Log level value: for significant messages.
   */
  public static int INFO = 800;

  /**
   * Log level value: for config information in debugging.
   */
  public static int CONFIG = 700;

  /**
   * Log level value: for information such as recoverable failures.
   */
  public static int FINE = 500;

  /**
   * Log level value: for information about entering or returning a 
   * method, or throwing an exception.
   */
  public static int FINER = 400;

  /**
   * Log level value: for detail tracing information.
   */
  public static int FINEST = 300;


  static Logger logger;

  static {
    logger = Logger.getLogger("");
  }

  public Alog() {
  }

  public static void alert(String subject, String message) {
  }

  public static void error(String text, int level, String fullClassName, 
  String methodName, String baseFileName, int lineNumber) {
    String[] para = {lineNumber + "", baseFileName};
    logger.logp(getLevel(level), fullClassName, methodName, text, para);
  }

  public static Level getLevel(int levelValue) {
    if (levelValue == SEVERE)
      return Level.SEVERE;
    else if (levelValue == WARNING)
      return Level.WARNING;
    else if (levelValue == INFO)
      return Level.INFO;
    else if (levelValue == CONFIG)
      return Level.CONFIG;
    else if (levelValue == FINE)
      return Level.FINE;
    else if (levelValue == FINER)
      return Level.FINER;
    else if (levelValue == FINEST)
      return Level.FINEST;
    else 
      return Level.ALL;
  }

  public static void log(String text, int level, String fullClassName, 
  String methodName, String baseFileName, int lineNumber) {
    String[] para = {lineNumber + "", baseFileName};
    logger.logp(getLevel(level), fullClassName, methodName, text, para);
  }

  public static void sendMail(String to, String from, String subject, 
  String text) throws Exception {
  }

  public static void sendMail(String to, String cc, String bcc, String from, 
  String subject, String text) throws Exception {
  }
}
