Skip to content

Commit

Permalink
fully wrap threadstone logger's operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Mar 15, 2023
1 parent 0f4e8d3 commit 2bda7b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions patches/net/minecraft/block/BlockBeacon.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@
Chunk chunk = worldIn.getChunk(glassPos);

for (int i = glassPos.getY() - 1; i >= 0; --i)
@@ -111,7 +123,16 @@
@@ -111,7 +123,20 @@
});
}
}
+ // vanilla logic ends

+ // TISCM threadstone logger logs beacons add catch-finally
+ } catch (Throwable throwable) {
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
+ if (logBeacons) {
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
+ } else {
+ throw throwable;
+ }
+ } finally {
+ if (logBeacons) {
+ GlassThreadStatistic.getInstance().onGlassThreadTerminated(System.nanoTime() - startNano);
Expand Down
9 changes: 6 additions & 3 deletions patches/net/minecraft/block/BlockNote.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
if (flag)
{
this.triggerNote(worldIn, pos);
@@ -55,6 +76,57 @@
@@ -55,6 +76,60 @@
}
}

Expand Down Expand Up @@ -83,7 +83,10 @@
+ }
+ catch (Throwable throwable)
+ {
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
+ if (CarpetSettings.threadstoneLogger && LoggerRegistry.__threadstone)
+ {
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
+ }
+ }
+ });
+ }
Expand Down Expand Up @@ -112,7 +115,7 @@
private void triggerNote(World worldIn, BlockPos pos)
{
if (worldIn.getBlockState(pos.up()).isAir())
@@ -101,4 +173,16 @@
@@ -101,4 +176,16 @@
{
builder.add(INSTRUMENT, POWERED, NOTE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ private void logFormat(String formatter, Object... args) {
this.logText(Messenger.format(formatter, args));
}

// ============================= hooks =============================
// all hooks should be checked using CarpetSettings.threadstoneLogger && LoggerRegistry.__threadstone
// to ensure that they only get triggered when necessary

public void onExceptionallyEndedAsyncThread(Throwable throwable) {
this.logFormat("Exception occurred: %s", throwable);
}
Expand Down

0 comments on commit 2bda7b5

Please sign in to comment.