1 18 package org.objectweb.speedo.jmx; 19 20 import org.objectweb.util.monolog.Monolog; 21 import org.objectweb.util.monolog.api.BasicLevel; 22 import org.objectweb.util.monolog.api.Logger; 23 24 29 public class MX4JLoggerMonolog extends mx4j.log.Logger { 30 31 34 Logger logger; 35 36 39 public MX4JLoggerMonolog() { 40 } 41 42 46 public MX4JLoggerMonolog(Logger lo) { 47 this.logger = lo; 48 } 49 50 54 protected void setCategory(String name) { 55 super.setCategory(name); 56 logger = Monolog.monologFactory.getLogger(name); 57 } 58 59 62 public void setPriority(int p) { 63 super.setPriority(p); 64 logger.setIntLevel(priority2Level(p)); 65 } 66 67 70 private final static int priority2Level(int p) { 71 switch (p) { 72 case mx4j.log.Logger.FATAL: 73 return BasicLevel.FATAL; 74 case mx4j.log.Logger.ERROR: 75 return BasicLevel.ERROR; 76 case mx4j.log.Logger.WARN: 77 return BasicLevel.WARN; 78 case mx4j.log.Logger.INFO: 79 return BasicLevel.INFO; 80 case mx4j.log.Logger.DEBUG: 81 default: 82 return BasicLevel.DEBUG; 83 } 84 } 85 86 89 protected void log(int p, Object m, Throwable t) { 90 if (t == null) { 91 logger.log(priority2Level(p), m); 92 } else { 93 logger.log(priority2Level(p), m, t); 94 } 95 } 96 } 97 | Popular Tags |