All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.ssc.log.SscFormatter Maven / Gradle / Ivy

Go to download

This is a JSR331 interface for SSC (Software for the Calculation of the Simplex) is a java library for solving linear programming problems v. 3.0.1. SSC was designed and developed by Stefano Scarioli.

The newest version!
package it.ssc.log;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import it.ssc.context.Config;


public final class SscFormatter extends Formatter { 
	
	private static final DateFormat sdf = new SimpleDateFormat("dd/MM/yy kk:mm:ss"); 
	private static final String LINE_SEPARATOR = Config.NL;
	
	@Override
	public String format(LogRecord arg0) {
		StringBuffer buffer=new StringBuffer();
		buffer.append(sdf.format(new Date()));
		buffer.append(" - ");
		buffer.append(replaceSevereWhitError(arg0));
		buffer.append(": ");
		buffer.append(arg0.getMessage());
		buffer.append(LINE_SEPARATOR); 
		return buffer.toString();
	}
	
	private static String replaceSevereWhitError(LogRecord arg0)  {
		Level level=arg0.getLevel();
		if(level.intValue()==Level.SEVERE.intValue()) return "ERROR SEVERE";
		return level.getName();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy