1
0
mirror of https://github.com/lucko/LuckPerms.git synced 2025-09-25 05:21:29 +02:00

Add checkTime property to verbose data (#2226)

This commit is contained in:
Luck
2020-04-26 10:49:52 +01:00
parent f484e87828
commit c03aca35d6
4 changed files with 20 additions and 7 deletions

View File

@@ -80,11 +80,12 @@ public class VerboseHandler implements AutoCloseable {
return; return;
} }
long time = System.currentTimeMillis();
Throwable trace = new Throwable(); Throwable trace = new Throwable();
String thread = Thread.currentThread().getName(); String thread = Thread.currentThread().getName();
// add the check data to a queue to be processed later. // add the check data to a queue to be processed later.
this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkQueryOptions, trace, thread, permission, result)); this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkQueryOptions, time, trace, thread, permission, result));
} }
/** /**
@@ -105,11 +106,12 @@ public class VerboseHandler implements AutoCloseable {
return; return;
} }
long time = System.currentTimeMillis();
Throwable trace = new Throwable(); Throwable trace = new Throwable();
String thread = Thread.currentThread().getName(); String thread = Thread.currentThread().getName();
// add the check data to a queue to be processed later. // add the check data to a queue to be processed later.
this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkQueryOptions, trace, thread, key, result)); this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkQueryOptions, time, trace, thread, key, result));
} }
/** /**

View File

@@ -46,8 +46,8 @@ public class MetaCheckEvent extends VerboseEvent {
*/ */
private final String result; private final String result;
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String key, String result) { public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread, String key, String result) {
super(checkTarget, checkQueryOptions, checkTrace, checkThread); super(checkTarget, checkQueryOptions, checkTime, checkTrace, checkThread);
this.origin = origin; this.origin = origin;
this.key = key; this.key = key;
this.result = result; this.result = result;

View File

@@ -47,8 +47,8 @@ public class PermissionCheckEvent extends VerboseEvent {
*/ */
private final TristateResult result; private final TristateResult result;
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String permission, TristateResult result) { public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread, String permission, TristateResult result) {
super(checkTarget, checkQueryOptions, checkTrace, checkThread); super(checkTarget, checkQueryOptions, checkTime, checkTrace, checkThread);
this.origin = origin; this.origin = origin;
this.permission = permission; this.permission = permission;
this.result = result; this.result = result;

View File

@@ -53,6 +53,11 @@ public abstract class VerboseEvent implements VariableEvaluator {
*/ */
private final QueryOptions checkQueryOptions; private final QueryOptions checkQueryOptions;
/**
* The time when the check took place
*/
private final long checkTime;
/** /**
* The throwable created when the check took place * The throwable created when the check took place
*/ */
@@ -63,9 +68,10 @@ public abstract class VerboseEvent implements VariableEvaluator {
*/ */
private final String checkThread; private final String checkThread;
protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread) { protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread) {
this.checkTarget = checkTarget; this.checkTarget = checkTarget;
this.checkQueryOptions = checkQueryOptions; this.checkQueryOptions = checkQueryOptions;
this.checkTime = checkTime;
this.checkTrace = checkTrace; this.checkTrace = checkTrace;
this.checkThread = checkThread; this.checkThread = checkThread;
} }
@@ -78,6 +84,10 @@ public abstract class VerboseEvent implements VariableEvaluator {
return this.checkQueryOptions; return this.checkQueryOptions;
} }
public long getCheckTime() {
return this.checkTime;
}
public StackTraceElement[] getCheckTrace() { public StackTraceElement[] getCheckTrace() {
return this.checkTrace.getStackTrace(); return this.checkTrace.getStackTrace();
} }
@@ -105,6 +115,7 @@ public abstract class VerboseEvent implements VariableEvaluator {
); );
} }
}) })
.add("time", this.checkTime)
.add("trace", new JArray() .add("trace", new JArray()
.consume(arr -> { .consume(arr -> {
int overflow = tracePrinter.process(getCheckTrace(), StackTracePrinter.elementToString(arr::add)); int overflow = tracePrinter.process(getCheckTrace(), StackTracePrinter.elementToString(arr::add));