mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Add checkTime property to verbose data (#2226)
This commit is contained in:
parent
f484e87828
commit
c03aca35d6
@ -80,11 +80,12 @@ public class VerboseHandler implements AutoCloseable {
|
||||
return;
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
Throwable trace = new Throwable();
|
||||
String thread = Thread.currentThread().getName();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
Throwable trace = new Throwable();
|
||||
String thread = Thread.currentThread().getName();
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,8 +46,8 @@ public class MetaCheckEvent extends VerboseEvent {
|
||||
*/
|
||||
private final String result;
|
||||
|
||||
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String key, String result) {
|
||||
super(checkTarget, checkQueryOptions, checkTrace, checkThread);
|
||||
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread, String key, String result) {
|
||||
super(checkTarget, checkQueryOptions, checkTime, checkTrace, checkThread);
|
||||
this.origin = origin;
|
||||
this.key = key;
|
||||
this.result = result;
|
||||
|
@ -47,8 +47,8 @@ public class PermissionCheckEvent extends VerboseEvent {
|
||||
*/
|
||||
private final TristateResult result;
|
||||
|
||||
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String permission, TristateResult result) {
|
||||
super(checkTarget, checkQueryOptions, checkTrace, checkThread);
|
||||
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread, String permission, TristateResult result) {
|
||||
super(checkTarget, checkQueryOptions, checkTime, checkTrace, checkThread);
|
||||
this.origin = origin;
|
||||
this.permission = permission;
|
||||
this.result = result;
|
||||
|
@ -53,6 +53,11 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
*/
|
||||
private final QueryOptions checkQueryOptions;
|
||||
|
||||
/**
|
||||
* The time when the check took place
|
||||
*/
|
||||
private final long checkTime;
|
||||
|
||||
/**
|
||||
* The throwable created when the check took place
|
||||
*/
|
||||
@ -63,9 +68,10 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
*/
|
||||
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.checkQueryOptions = checkQueryOptions;
|
||||
this.checkTime = checkTime;
|
||||
this.checkTrace = checkTrace;
|
||||
this.checkThread = checkThread;
|
||||
}
|
||||
@ -78,6 +84,10 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
return this.checkQueryOptions;
|
||||
}
|
||||
|
||||
public long getCheckTime() {
|
||||
return this.checkTime;
|
||||
}
|
||||
|
||||
public StackTraceElement[] getCheckTrace() {
|
||||
return this.checkTrace.getStackTrace();
|
||||
}
|
||||
@ -105,6 +115,7 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
);
|
||||
}
|
||||
})
|
||||
.add("time", this.checkTime)
|
||||
.add("trace", new JArray()
|
||||
.consume(arr -> {
|
||||
int overflow = tracePrinter.process(getCheckTrace(), StackTracePrinter.elementToString(arr::add));
|
||||
|
Loading…
Reference in New Issue
Block a user