Browse Source

added log (was ignored, somehow..)

Cláudio Gomes 3 years ago
parent
commit
dcc3abdd81

+ 11 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.log/META-INF/MANIFEST.MF

@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: be.uantwerpen.ansymo.semanticadaptation.log
+Bundle-Vendor: University of Antwerp, Ansymo Lab
+Bundle-Version: 1.0.0.qualifier
+Bundle-SymbolicName: be.uantwerpen.ansymo.semanticadaptation.log; singleton:=true
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Import-Package: org.apache.log4j
+Export-Package: be.uantwerpen.ansymo.semanticadaptation.log
+Require-Bundle: org.eclipse.xtext.xbase.lib;bundle-version="2.11.0"

+ 20 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.log/build.properties

@@ -0,0 +1,20 @@
+source.. = src/,\
+           src-gen/,\
+           xtend-gen/
+bin.includes = .,\
+               META-INF/,\
+               plugin.xml
+additional.bundles = org.eclipse.xtext.xbase,\
+                     org.eclipse.xtext.common.types,\
+                     org.eclipse.xtext.xtext.generator,\
+                     org.eclipse.emf.codegen.ecore,\
+                     org.eclipse.emf.mwe.utils,\
+                     org.eclipse.emf.mwe2.launch,\
+                     org.eclipse.emf.mwe2.lib,\
+                     org.objectweb.asm,\
+                     org.apache.commons.logging,\
+                     org.apache.log4j,\
+                     com.ibm.icu
+src.includes = src/,\
+               plugin.xml,\
+               META-INF/

+ 5 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.log/plugin.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="windows-1252"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+</plugin>

+ 34 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.log/pom.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<relativePath>../pom.xml</relativePath>
+		<groupId>be.uantwerpen.ansymo.semanticadaptation</groupId>
+		<artifactId>parent</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>be.uantwerpen.ansymo.semanticadaptation.log</artifactId>
+	<packaging>eclipse-plugin</packaging>
+
+	<name>be.uantwerpen.ansymo.semanticadaptation Logger</name>
+
+	<properties>
+    <main.basedir>${project.parent.basedir}</main.basedir>
+	</properties>
+
+	<dependencies>
+		
+	</dependencies>
+
+	<build>
+			<plugins>
+				<plugin>
+					<groupId>org.eclipse.xtend</groupId>
+					<artifactId>xtend-maven-plugin</artifactId>
+				</plugin>
+			</plugins>
+	</build>
+
+</project>

+ 63 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.log/src/be/uantwerpen/ansymo/semanticadaptation/log/Log.xtend

@@ -0,0 +1,63 @@
+package be.uantwerpen.ansymo.semanticadaptation.log
+
+import org.apache.log4j.ConsoleAppender
+import org.apache.log4j.Level
+import org.apache.log4j.LogManager
+import org.apache.log4j.Logger
+import org.apache.log4j.PatternLayout
+
+class Log {
+	var static Log l = null;
+	
+	var c = 0
+	
+	private static Logger logger;
+	
+	protected new() {
+		LogManager.resetConfiguration();
+		val console = new ConsoleAppender(); // create appender
+		// configure the appender
+		val PATTERN = "%d [%p] %m%n";
+		console.setLayout(new PatternLayout(PATTERN));
+		console.setThreshold(Level.DEBUG);
+		console.activateOptions();
+		// add appender to any Logger (here is root)
+		Logger.getRootLogger().addAppender(console);
+		
+		logger = Logger.getLogger("L")
+		logger.info("Logger initialized.")
+	}
+
+	def protected static Log gl() {
+		if (l === null) {
+			l = new Log();
+		}
+		return l;
+	}
+	
+	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')){
+			logger.info(space + line)
+		}
+	}
+	
+	def static void push(String msg){
+		logger.info(space(gl().c) + ">" + msg)
+		gl().c++
+	}
+	
+	def static void pop(String msg){
+		gl().c--
+		logger.info(space(gl().c) + "<" + msg)
+	}
+	
+}