001 /* 002 @license.text@ 003 */ 004 package biz.hammurapi.metrics; 005 006 import java.util.Date; 007 008 import org.apache.log4j.Logger; 009 010 /** 011 * @author Pavel Vlasov 012 */ 013 public class Log4jInfoSliceConsumer implements SliceConsumer { 014 015 public boolean consumeSlice(String category, Slice slice) { 016 StringBuffer msg=new StringBuffer(category); 017 msg.append(": "); 018 msg.append("Name="+slice.getName()); 019 msg.append("; Total="+slice.getTotal()); 020 msg.append("; Avg="+slice.getAvg()); 021 msg.append("; Min="+slice.getMin()); 022 msg.append("; Max="+slice.getMax()); 023 msg.append("; Deviation="+slice.getDeviation()); 024 msg.append("; From="+slice.getFrom()+" ("+new Date(slice.getFrom())+")"); 025 msg.append("; To="+slice.getTo()+" ("+new Date(slice.getTo())+")"); 026 msg.append("; Measurements="+slice.getNumber()); 027 Logger.getLogger(category).info(msg.toString()); 028 return true; 029 } 030 }