Home | History | Annotate | Download | only in util
      1 package com.jme3.util;
      2 
      3 import android.util.Log;
      4 import java.util.logging.Handler;
      5 import java.util.logging.Level;
      6 import java.util.logging.LogRecord;
      7 import java.util.logging.Logger;
      8 
      9 /**
     10  * Converts from Java based logging ({@link Logger} to Android based
     11  * logging {@link Log}.
     12  */
     13 public class AndroidLogHandler extends Handler {
     14 
     15     @Override
     16     public void close() {
     17     }
     18 
     19     @Override
     20     public void flush() {
     21     }
     22 
     23     @Override
     24     public void publish(LogRecord record) {
     25         Level level = record.getLevel();
     26         String clsName = record.getSourceClassName();
     27         String msg = record.getMessage();
     28         Throwable t = record.getThrown();
     29         if (level == Level.INFO) {
     30             Log.i(clsName, msg, t);
     31         } else if (level == Level.SEVERE) {
     32             Log.e(clsName, msg, t);
     33         } else if (level == Level.WARNING) {
     34             Log.w(clsName, msg, t);
     35         } else if (level == Level.CONFIG) {
     36             Log.d(clsName, msg, t);
     37         } else if (level == Level.FINE || level == Level.FINER || level == Level.FINEST) {
     38             Log.v(clsName, msg, t);
     39         }
     40     }
     41 }
     42