Skip to content

Commit 81a42e9

Browse files
author
notefox
committed
half tested ProcessRunner
1 parent 197f8d1 commit 81a42e9

20 files changed

Lines changed: 1201 additions & 329 deletions

pom.xml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,36 @@
4040
<version>3.6.28</version>
4141
<scope>test</scope>
4242
</dependency>
43+
44+
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-report-plugin -->
45+
<dependency>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-surefire-report-plugin</artifactId>
48+
<version>3.0.0-M5</version>
49+
</dependency>
50+
51+
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin -->
52+
<dependency>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-site-plugin</artifactId>
55+
<version>3.9.1</version>
56+
</dependency>
57+
58+
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-deploy-plugin -->
59+
<dependency>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-deploy-plugin</artifactId>
62+
<version>3.0.0-M1</version>
63+
</dependency>
64+
65+
<!-- added by jetbrains -->
4366
<dependency>
4467
<groupId>org.jetbrains</groupId>
4568
<artifactId>annotations</artifactId>
4669
<version>RELEASE</version>
4770
<scope>compile</scope>
4871
</dependency>
4972

50-
5173
</dependencies>
5274

5375
<build>
@@ -57,6 +79,43 @@
5779
<artifactId>maven-surefire-plugin</artifactId>
5880
<version>3.0.0-M5</version>
5981
</plugin>
82+
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-surefire-report-plugin</artifactId>
86+
<version>3.0.0-M5</version>
87+
</plugin>
88+
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-deploy-plugin</artifactId>
92+
<version>3.0.0-M1</version>
93+
<executions>
94+
<execution>
95+
<phase>deploy</phase>
96+
<goals>
97+
<goal>deploy</goal>
98+
</goals>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-site-plugin</artifactId>
106+
<version>3.9.1</version>
107+
<configuration>
108+
<locales>en</locales>
109+
</configuration>
110+
<executions>
111+
<execution>
112+
<phase>site</phase>
113+
<goals>
114+
<goal>site</goal>
115+
</goals>
116+
</execution>
117+
</executions>
118+
</plugin>
60119
</plugins>
61120
</build>
62121

src/main/java/Logger/LogEntry.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package Logger;
2+
3+
/**
4+
* log entry class
5+
*/
6+
public class LogEntry {
7+
8+
/**
9+
* log type
10+
*/
11+
public LogType type;
12+
13+
/**
14+
* log tag
15+
*/
16+
public String TAG;
17+
18+
/**
19+
* log message
20+
*/
21+
public String message;
22+
23+
/**
24+
* constructor
25+
* @param type type
26+
* @param TAG tag
27+
* @param message message
28+
*/
29+
public LogEntry(LogType type, String TAG, String message) {
30+
this.type = type;
31+
this.TAG = TAG;
32+
this.message = message;
33+
}
34+
35+
/**
36+
* type getter
37+
* @return LogType
38+
*/
39+
public LogType getType() {
40+
return type;
41+
}
42+
43+
/**
44+
* tag getter
45+
* @return String
46+
*/
47+
public String getTAG() {
48+
return TAG;
49+
}
50+
51+
/**
52+
* message getter
53+
* @return String
54+
*/
55+
public String getMessage() {
56+
return message;
57+
}
58+
}

src/main/java/Logger/LogType.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package Logger;
2+
3+
/**
4+
* log type enum
5+
*/
6+
public enum LogType {
7+
DEBUG("[DEBUG]"),
8+
ERROR("[ERROR]"),
9+
INFO("[INFO]"),
10+
MESSAGE("[MESSAGE]"),
11+
WARNING("[WARNING]");
12+
13+
/**
14+
* constructor
15+
* @param s log type
16+
*/
17+
LogType(String s) {
18+
19+
}
20+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package Logger;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
6+
/**
7+
* loggable object frame
8+
*/
9+
public class LoggableObject {
10+
11+
/**
12+
* logger used
13+
*/
14+
private final Logger logger;
15+
16+
/**
17+
* Object tag
18+
*/
19+
private final String tag;
20+
21+
/**
22+
* constructor
23+
* @param tag class tag for LogEntry
24+
* @param filePrefix logfile prefix
25+
* @param logDefaultDir logger default directory
26+
* @param maxLogFileSize max log file size in MB
27+
* @param logTerminalOutput System.out::print bit
28+
* @throws IOException is thrown, if the logger has problems with the given file path
29+
*/
30+
public LoggableObject(String tag, String filePrefix, File logDefaultDir, int maxLogFileSize, boolean logTerminalOutput) throws IOException {
31+
this.tag = tag;
32+
this.logger = new Logger(filePrefix, logDefaultDir, maxLogFileSize, logTerminalOutput);
33+
this.logger.start();
34+
}
35+
36+
/**
37+
* log method for class
38+
* @param type log type
39+
* @param message log message
40+
*/
41+
protected void log(LogType type, String message) {
42+
if (logger == null) {
43+
// ignore
44+
return;
45+
}
46+
logger.addLogEntry(type, tag, message);
47+
}
48+
}

0 commit comments

Comments
 (0)