Browse Source

changed logger to use log4j

Cláudio Gomes 3 years ago
parent
commit
ef2c3be0bb

+ 14 - 12
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/Log.xtend

@@ -1,10 +1,14 @@
 package be.uantwerpen.ansymo.semanticadaptation.generator
 
+import org.apache.log4j.Logger
+
 class Log {
 	var static Log l = null;
 	
 	var c = 0
 	
+	private static final Logger logger = Logger.getLogger("");
+	
 	protected new() {
 		// Exists only to defeat instantiation.
 	}
@@ -16,31 +20,29 @@ class Log {
 		return l;
 	}
 	
-	def static void space(){
-		for (var i=0; i<gl().c; i++){
-			System.out.print(" ")
+	def static String space(int indent){
+		var res = ""
+		for(var i = 0; i<indent; i++){
+			res += " "
 		}
+		return res;
 	}
-	
+
 	def static void println(String msg){
+		val space = space(gl().c)
 		for(line : msg.split('\n')){
-			space()
-			System.out.println(line)
+			logger.info(space + line)
 		}
 	}
 	
 	def static void push(String msg){
-		space()
-		System.out.print(">")
-		System.out.println(msg)
+		logger.info(space(gl().c) + ">" + msg)
 		gl().c++
 	}
 	
 	def static void pop(String msg){
 		gl().c--
-		space()
-		System.out.print("<")
-		System.out.println(msg)
+		logger.info(space(gl().c) + "<" + msg)
 	}
 	
 }