Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

add integration test #1

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
24 changes: 23 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.eclipse.tracecompass</groupId>
<artifactId>trace-event-logger</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.3-SNAPSHOT</version>

<name>trace-event-logger</name>
<!-- the project's website -->
Expand All @@ -30,6 +30,28 @@
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>benchmarks</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,24 @@ public AsyncFileHandler() throws SecurityException, IOException {
this(""); // let's hope it's configured in logging properties.
}

/**
* Asynchronous file handler, wraps a {@link FileHandler} behind a thread
*
* @param pattern the file pattern
* @throws SecurityException
* @throws IOException
*/
public AsyncFileHandler(String pattern) throws SecurityException, IOException {
configure();
fileHandler = new FileHandler(pattern);
fileHandler.setEncoding(encoding);
fileHandler.setErrorManager(errorManager);
fileHandler.setFilter(filter);
fileHandler.setLevel(level);
if (encoding != null)
fileHandler.setEncoding(encoding);
if (errorManager != null)
fileHandler.setErrorManager(errorManager);
if (filter != null)
fileHandler.setFilter(filter);
if (level != null)
fileHandler.setLevel(level);

queue = new ArrayBlockingQueue<>(queueDepth);
timer.scheduleAtFixedRate(task, flushRate, flushRate);
Expand Down Expand Up @@ -277,7 +288,7 @@ public ErrorManager getErrorManager() {
public synchronized void publish(LogRecord record) {
try {
recordBuffer.add(record);
if (recordBuffer.size() >= maxSize) {
if (recordBuffer.size() >= maxSize && isLoggable(record)) {
queue.put(recordBuffer);
recordBuffer = new ArrayList<>(maxSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,52 @@

class InnerEvent {

public static InnerEvent create(LogRecord lRecord) {
if (lRecord instanceof LogUtils.TraceEventLogRecord) {
TraceEventLogRecord rec = (TraceEventLogRecord) lRecord;
double ts = (double) rec.getParameters()[0];
String phase = (String) rec.getParameters()[1];
String pid = (String) rec.getParameters()[2];
String tid = (String) rec.getParameters()[2];
return new InnerEvent(rec, ts, phase, pid, tid);
}
return null;
}
public static InnerEvent create(LogRecord lRecord) {
if (lRecord instanceof LogUtils.TraceEventLogRecord) {
TraceEventLogRecord rec = (TraceEventLogRecord) lRecord;
Object[] parameters = rec.getParameters();
if (parameters != null && parameters.length >= 3) {
double ts = ((Long) parameters[0]).longValue()*0.001;
String phase = String.valueOf(parameters[1]);
String pid = String.valueOf(parameters[2]);
String tid = String.valueOf(parameters[2]);
return new InnerEvent(rec, ts, phase, pid, tid);
}
}
return null;
}

private final LogRecord message;
private final double ts;
private final String tid;
private final String pid;
private final String phase;
private final LogRecord message;
private final double ts;
private final String tid;
private final String pid;
private final String phase;

public InnerEvent(LogRecord message, double ts, String phase, String pid, String tid) {
this.message = message;
this.ts = ts;
this.phase = phase;
this.tid = tid;
this.pid = pid;
}
public InnerEvent(LogRecord message, double ts, String phase, String pid, String tid) {
this.message = message;
this.ts = ts;
this.phase = phase;
this.tid = tid;
this.pid = pid;
}

public String getMessage() {
return message.getMessage();
}
public String getMessage() {
return message.getMessage();
}

public double getTs() {
return ts;
}
public double getTs() {
return ts;
}

public String getTid() {
return tid;
}
public String getTid() {
return tid;
}

public String getPid() {
return pid;
}
public String getPid() {
return pid;
}

public String getPhase() {
return phase;
}
public String getPhase() {
return phase;
}
}
Loading