Skip to content

Commit

Permalink
Merge pull request #13 from FIUS/feature/ui-console
Browse files Browse the repository at this point in the history
Add logging and a console to show the logs
  • Loading branch information
neumantm authored Sep 11, 2019
2 parents 9dc95f9 + a0107e1 commit 899a296
Show file tree
Hide file tree
Showing 19 changed files with 982 additions and 12 deletions.
1 change: 1 addition & 0 deletions ICGE-Log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
23 changes: 23 additions & 0 deletions ICGE-Log/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ICGE-Log</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
6 changes: 6 additions & 0 deletions ICGE-Log/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
2 changes: 2 additions & 0 deletions ICGE-Log/.settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
490 changes: 490 additions & 0 deletions ICGE-Log/.settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions ICGE-Log/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=true
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.always_use_blocks=false
cleanup.always_use_parentheses_in_expressions=true
cleanup.always_use_this_for_non_static_field_access=true
cleanup.always_use_this_for_non_static_method_access=true
cleanup.convert_functional_interfaces=true
cleanup.convert_to_enhanced_for_loop=false
cleanup.correct_indentation=true
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.insert_inferred_type_arguments=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=true
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=false
cleanup.organize_imports=true
cleanup.qualify_static_field_accesses_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=true
cleanup.remove_private_constructors=true
cleanup.remove_redundant_modifiers=true
cleanup.remove_redundant_semicolons=true
cleanup.remove_redundant_type_arguments=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=false
cleanup.remove_trailing_whitespaces_ignore_empty=true
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=false
cleanup.remove_unused_local_variables=true
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=true
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.use_anonymous_class_creation=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=true
cleanup.use_lambda=true
cleanup.use_parentheses_in_expressions=true
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=false
cleanup.use_this_for_non_static_method_access=true
cleanup.use_this_for_non_static_method_access_only_if_necessary=false
cleanup_profile=_ICGE
cleanup_settings_version=2
eclipse.preferences.version=1
formatter_profile=_ICGE
formatter_settings_version=16
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=java;javax;org;com;
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.keywordthis=true
org.eclipse.jdt.ui.ondemandthreshold=10
org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.staticondemandthreshold=3
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * Get's {@link \#${field} ${bare_field_name}}\n * @return ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * Set's {@link \#${field} ${bare_field_name}}\n * @param ${param} ${bare_field_name}\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * This source file is part of the FIUS ICGE project.\n * For more information see github.com/FIUS/ICGE2\n *\n * Copyright (c) 2019 the ICGE project authors.\n * \n * This software is available under the MIT license.\n * SPDX-License-Identifier\: MIT\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * TODO\: Description\n * @author ${name\:git_config(user.name)}\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
2 changes: 2 additions & 0 deletions ICGE-Log/.settings/org.eclipse.ltk.core.refactoring.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
4 changes: 4 additions & 0 deletions ICGE-Log/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
12 changes: 12 additions & 0 deletions ICGE-Log/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.uni-stuttgart.informatik.fius</groupId>
<artifactId>ICGE</artifactId>
<version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>ICGE-Log</artifactId>
<name>ICGE Log</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
*
* Copyright (c) 2019 the ICGE project authors.
*
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
package de.unistuttgart.informatik.fius.icge.log;

import java.io.OutputStream;
import java.io.PrintStream;


/**
* The main class for all the logging.
*
* @author Tim Neumann
* @author Tobias Wältken
* @version 1.0
*/
public abstract class Logger {

/** The logger for the simulation */
public static PrintStream simulation;
/** The main logger printing to {@link System#out} */
public static PrintStream out;
/** The error logger printing to {@link System#err} */
public static PrintStream error;

private static OutputStreamMultiplier simulationStream;
private static OutputStreamMultiplier outStream;
private static OutputStreamMultiplier errorStream;

// This block setups all the loggers and intercepts {@link System.out} and {@link System.err}
static {
Logger.simulationStream = new OutputStreamMultiplier();
Logger.simulation = new PrintStream(Logger.simulationStream);

Logger.outStream = new OutputStreamMultiplier();
Logger.out = new PrintStream(Logger.outStream);
Logger.outStream.addOutputStream(System.out);
System.setOut(Logger.out);

Logger.errorStream = new OutputStreamMultiplier();
Logger.error = new PrintStream(Logger.errorStream);
Logger.errorStream.addOutputStream(System.err);
System.setErr(Logger.error);
}

/**
* Function to add a {@link OutputStream} to the simulation logger
*
* @param stream
* The {@link OutputStream} to add
* @return Returns true if successfull
* @see OutputStreamMultiplier#addOutputStream(OutputStream)
*/
public static boolean addSimulationOutputStream(final OutputStream stream) {
return Logger.simulationStream.addOutputStream(stream);
}

/**
* Function to remove a {@link OutputStream} from the simulation logger
*
* @param stream
* The {@link OutputStream} to remove
* @return Returns true if successfull
* @see OutputStreamMultiplier#removeOutputStream(OutputStream)
*/
public static boolean removeSimulationOutputStream(final OutputStream stream) {
return Logger.simulationStream.removeOutputStream(stream);
}

/**
* Clears the simulation OutputStreams
*
* @see OutputStreamMultiplier#clearOutputStreams()
*/
public static void clearSimulationOutputStream() {
Logger.simulationStream.clearOutputStreams();
}

/**
* Function to add a {@link OutputStream} to the out logger
*
* @param stream
* The {@link OutputStream} to add
* @return Returns true if successfull
* @see OutputStreamMultiplier#addOutputStream(OutputStream)
*/
public static boolean addOutOutputStream(final OutputStream stream) {
return Logger.outStream.addOutputStream(stream);
}

/**
* Function to remove a {@link OutputStream} from the out logger
*
* @param stream
* The {@link OutputStream} to remove
* @return Returns true if successfull
* @see OutputStreamMultiplier#removeOutputStream(OutputStream)
*/
public static boolean removeOutOutputStream(final OutputStream stream) {
return Logger.outStream.removeOutputStream(stream);
}

/**
* Clears the out OutputStreams
*
* @see OutputStreamMultiplier#clearOutputStreams()
*/
public static void clearOutOutputStream() {
Logger.outStream.clearOutputStreams();
}

/**
* Function to add a {@link OutputStream} to the error logger
*
* @param stream
* The {@link OutputStream} to add
* @return Returns true if successfull
* @see OutputStreamMultiplier#addOutputStream(OutputStream)
*/
public static boolean addErrorOutputStream(final OutputStream stream) {
return Logger.errorStream.addOutputStream(stream);
}

/**
* Function to remove a {@link OutputStream} from the error logger
*
* @param stream
* The {@link OutputStream} to remove
* @return Returns true if successfull
* @see OutputStreamMultiplier#removeOutputStream(OutputStream)
*/
public static boolean removeErrorOutputStream(final OutputStream stream) {
return Logger.errorStream.removeOutputStream(stream);
}

/**
* Clears the error OutputStreams
*
* @see OutputStreamMultiplier#clearOutputStreams()
*/
public static void clearErrorOutputStream() {
Logger.errorStream.clearOutputStreams();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
*
* Copyright (c) 2019 the ICGE project authors.
*
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
package de.unistuttgart.informatik.fius.icge.log;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;


/**
* A Output stream that allows multiple other output streams to attach themselves to this one.
*
* @author Tobias Wältken
* @version 1.0
*/
public class OutputStreamMultiplier extends OutputStream {

private final ArrayList<OutputStream> listenerStreams;

/**
* Default Constructor
*/
public OutputStreamMultiplier() {
this.listenerStreams = new ArrayList<>();
}

/**
* Add a output stream to also recieve everything this stream recieves
*
* @param listenerStream
* The stream to add
* @return Returns True if successfull
*/
public boolean addOutputStream(final OutputStream listenerStream) {
return this.listenerStreams.add(listenerStream);
}

/**
* Remove a output stream from recieving everything this stream recieves
*
* @param listenerStream
* The stream to remove
* @return Returns True if successfull
*/
public boolean removeOutputStream(final OutputStream listenerStream) {
return this.listenerStreams.remove(listenerStream);
}

/**
* Clears all connected output streams
*/
public void clearOutputStreams() {
this.listenerStreams.clear();
}

@Override
public void flush() throws IOException {
super.flush();

for (final OutputStream listenerStream : this.listenerStreams) {
listenerStream.flush();
}
}

@Override
public void write(final int arg0) throws IOException {
for (final OutputStream listenerStream : this.listenerStreams) {
listenerStream.write(arg0);
}
}
}
3 changes: 3 additions & 0 deletions ICGE-Log/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module de.unistuttgart.informatik.fius.icge.log {
exports de.unistuttgart.informatik.fius.icge.log;
}
6 changes: 5 additions & 1 deletion ICGE-Ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>de.uni-stuttgart.informatik.fius</groupId>
<artifactId>ICGE-Log</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
Expand All @@ -39,4 +43,4 @@
</build>
</profile>
</profiles>
</project>
</project>
Loading

0 comments on commit 899a296

Please sign in to comment.