package demo.transformers;

import java.util.Date;

import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;

import demo.domain.LogMessage;

public class LogMessageToString extends AbstractTransformer {

	@Override
	protected Object doTransform(Object src, String encoding)
			throws TransformerException {

		LogMessage lm = (LogMessage) src;

		StringBuffer sb = new StringBuffer();
		sb.append("The following LogMessage was received at "+new Date()).append("\n\n")
			.append("appName: "+lm.getAppName()).append("\n")
			.append("timeStamp: "+lm.getTimeStamp()).append("\n")
			.append("logLevel: "+lm.getLogLevel()).append("\n")
			.append("shortMsg: "+lm.getShortMsg()).append("\n")
			.append("longMsg: "+lm.getLongMsg())
			.append("\n\nPlease resolve this issue promptly!!!\n\nCheers,\nYour electronic leash :-)");

		return sb.toString();
	}

}
