--- /dev/null
+package mir.log;
+
+import mir.misc.MirConfig;
+
+
+public class Log {
+
+ private static Logger myLogger;
+
+ static {
+ try {
+ myLogger = (Logger)Class.forName(MirConfig.getProp("Log.LogClass")).newInstance();
+ }
+ catch (java.lang.ClassNotFoundException cnfe) {
+ System.err.println("Log was not able to initialize: class not found");
+ cnfe.printStackTrace(System.err);
+ }
+ catch (java.lang.InstantiationException ie) {
+ System.err.println("Log was not able to initialize: could not initialize class");
+ ie.printStackTrace(System.err);
+ }
+ catch (java.lang.IllegalAccessException iae) {
+ System.err.println("Log was not able to initialize: illegal access");
+ iae.printStackTrace(System.err);
+ }
+ }
+
+ public static void debug( Object o, String s) {
+ myLogger.debug( o, s );
+ }
+
+ public static void info( Object o, String s) {
+ myLogger.info( o, s );
+ }
+
+ public static void warn( Object o, String s) {
+ myLogger.warn( o, s );
+ }
+
+ public static void error( Object o, String s) {
+ myLogger.error( o, s );
+ }
+
+ public static void fatal( Object o, String s) {
+ myLogger.fatal( o, s );
+ }
+}
--- /dev/null
+package mir.log;
+
+
+public interface Logger {
+ public void debug( Object o, String s);
+ public void info( Object o, String s);
+ public void warn( Object o, String s);
+ public void error( Object o, String s);
+ public void fatal( Object o, String s);
+}
--- /dev/null
+package mir.log;
+
+import mir.log.Log;
+
+
+public class TestFramework {
+
+ public static void main(String[] args) {
+ TestFramework t = new TestFramework();
+
+ Log.info( TestFramework.class, "class");
+ Log.info( t, "object" );
+ Log.info( null, "lalala" );
+ }
+}
--- /dev/null
+package mir.log.log4j;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.Logger;
+
+import java.util.Map;
+import java.util.HashMap;
+
+
+public class LoggerImpl implements mir.log.Logger {
+
+ private static Map loggers = new HashMap();
+
+ public LoggerImpl() {
+ PropertyConfigurator.configure("log4j.properties");
+ }
+
+
+ public void debug( Object o, String s ) {
+ this.getLogger(o).debug(s);
+ }
+
+ public void info( Object o, String s ) {
+ this.getLogger(o).info(s);
+ }
+
+ public void warn( Object o, String s ) {
+ this.getLogger(o).warn(s);
+ }
+
+ public void error( Object o, String s ) {
+ this.getLogger(o).error(s);
+ }
+
+ public void fatal( Object o, String s ) {
+ this.getLogger(o).fatal(s);
+ }
+
+
+ private Logger getLogger( Object o ) {
+ String name;
+ if (o instanceof Class) {
+ name = ((Class)o).getName();
+ } else if (o!=null) {
+ name = o.getClass().getName();
+ } else {
+ name = "generic";
+ }
+
+ Logger l = (Logger)loggers.get(name);
+ if (l==null) {
+ l = Logger.getLogger(name);
+ loggers.put(name, l);
+ }
+ return l;
+ }
+}
\ No newline at end of file