package edu.gatech.grits.pancakes.core;

import org.apache.log4j.Level;

import edu.gatech.grits.pancakes.core.Stream.CommunicationException;
import edu.gatech.grits.pancakes.lang.LogPacket;
import edu.gatech.grits.pancakes.lang.Packet;

public class Syslog {
	
	private final void log(LogPacket pkt) {
		try {
			Kernel.stream.publish("log", pkt);
		} catch (CommunicationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public final void debug(String m) {
		//String src = (new Throwable()).getStackTrace()[1].getClassName();
		log(new LogPacket("syslog", Level.DEBUG, m));
	}
	
	public final void warn(String m) {
		log(new LogPacket("syslog", Level.WARN, m));
	}
	
	public final void info(String m) {
		log(new LogPacket("syslog", Level.INFO, m));
	}
	
	public final void fatal(String m) {
		log(new LogPacket("syslog", Level.FATAL, m));
	}
	
	public final void error(String m) {
		log(new LogPacket("syslog", Level.ERROR, m));
	}
	
	public final void tweet(String m) {
		log(new LogPacket("twitter", Level.INFO, m));
	}
	
	public final void record(Packet p) {
		log(new LogPacket("data", Level.INFO, Kernel.id + ":" + p.toString()));
	}
	
	public final void record(Packet p, String id){
		log(new LogPacket("data", Level.INFO, id + ":" + p.toString()));
	}
	
	public final void record(String tag, Packet p) {
		log(new LogPacket("data", Level.INFO, Kernel.id + ":" + tag + ":" + p.toString()));
	}
}

@@ -1434,10 +1434,98 @@
 )));%0A%09%7D%0A
+%09%0A%09public final void record(String m) %7B%0A%09%09log(new LogPacket(%22data%22, Level.INFO, m));%0A%09%7D%0A
 %7D%0A

Added a record function that writes a plain string.