-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/error logging system #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ammodev
wants to merge
55
commits into
version/1.21.11
Choose a base branch
from
feat/error-logging-system
base: version/1.21.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
afa848e
feat: implement error logging system for player connection failures
TheBjoRedCraft 51841df
feat: update error logging to use dynamic error code in PlayerConnect…
TheBjoRedCraft 38cd40e
feat: add core error command for viewing player errors and error codes
TheBjoRedCraft a0504ed
feat: enhance error logging and disconnect message handling in authen…
TheBjoRedCraft de1eb94
feat: refactor disconnect message handling to include error codes in …
TheBjoRedCraft ded7a43
feat: add error logging for failed authentication attempts in Authent…
TheBjoRedCraft a4f943d
feat: rename AuthentificationService to AuthenticationService and upd…
TheBjoRedCraft ef2f04f
feat: fix typo in logError method parameter name in SurfCoreApi
TheBjoRedCraft 14208a3
feat: add player UUID to error logging and enhance error details in S…
TheBjoRedCraft eb50f72
Initial plan
Copilot 505a898
feat: enhance error logging with stacktrace, location, and deduplication
Copilot 68beaf7
feat: implement separate system error logging infrastructure
Copilot 5ed9264
fix: address code review feedback - lifecycle management and code cle…
Copilot bc984a3
docs: add comprehensive implementation summary
Copilot 582d5d8
feat: add MCCoroutine exception event listeners for proper coroutine …
Copilot ee7d519
docs: remove IMPLEMENTATION_SUMMARY.md and SYSTEM_ERROR_LOGGING.md
Copilot a14d9bc
feat: implement error logging structure with improved server name han…
TheBjoRedCraft 21b9eab
Merge remote-tracking branch 'origin/copilot/implement-error-logging-…
TheBjoRedCraft d22f196
feat: add launch command to trigger exceptions for testing error hand…
TheBjoRedCraft 043b624
fix: correct /testerror coroutine to use suspend executor and add plu…
Copilot 2fa1c5a
feat: log error ID to console when errors are captured
Copilot dfdf5a6
fix: use upsert for atomic deduplication across restarts
Copilot d8516b6
refactor: remove documentation comments from code
Copilot c8267fe
refactor: rename SystemError to SurfCoreSystemError throughout codebase
Copilot 7f218cb
refactor: rename SystemError to SurfCoreSystemError in command and se…
TheBjoRedCraft 3e817de
Merge pull request #10 from SLNE-Development/copilot/implement-error-…
TheBjoRedCraft cd3cdb7
refactor: remove unnecessary plugin check from MCCoroutineExceptionLi…
TheBjoRedCraft a1fa50b
feat: update SurfCoreSystemError to use UUID and enhance error handli…
TheBjoRedCraft e495314
feat: enhance error logging with UUID and improve exception handling
TheBjoRedCraft a89726e
feat: improve error logging in MCCoroutineExceptionListener with stru…
TheBjoRedCraft 2c18455
feat: enhance error logging in MCCoroutineExceptionListener to includ…
TheBjoRedCraft 3f44235
feat: enhance error logging in SurfCoreSystemErrorCommand with hover …
TheBjoRedCraft cf3a1a3
feat: refine getLocationClassName method to improve class name extrac…
TheBjoRedCraft bf86af2
feat: enhance core error command with player and system error handling
TheBjoRedCraft d6462c5
Merge branch 'version/1.21.11' into feat/error-logging-system
TheBjoRedCraft 953e999
Initial plan
Copilot ad64038
Add 10-character error code system for system errors
Copilot 4945931
Add unique constraint to error code and implement retry mechanism
Copilot fc258fb
Remove ineffective retry mechanism, rely on database uniqueness
Copilot 102b407
Use error codes in command and logs for system errors
Copilot 5afb70a
Merge pull request #12 from SLNE-Development/copilot/add-error-code-f…
TheBjoRedCraft a392fdd
feat: enhance global error handling with detailed logging of exceptions
TheBjoRedCraft 4e58870
Initial plan
Copilot fdc7647
Add filtering support to error list commands
Copilot f693fd8
Fix query building to use proper where clause construction
Copilot 40023b2
Improve code quality: Extract common functions and reduce duplication
Copilot 69a2844
Extract andCondition helper to shared utility file
Copilot aec80dc
Merge pull request #13 from SLNE-Development/copilot/enhance-error-li…
TheBjoRedCraft d49107d
feat: rename QueryUtils.kt to query-util.kt and streamline error filt…
TheBjoRedCraft cfb02b5
feat: streamline error handling logic in CoreErrorCommand and SurfCor…
TheBjoRedCraft 5607948
feat: add error retrieval functionality for player and system errors …
TheBjoRedCraft 62169e0
feat: notify players of background system restart during proxy shutdown
TheBjoRedCraft d273a1f
Merge branch 'version/1.21.11' into feat/proxy-shutdown-broadcast-and…
TheBjoRedCraft cb78017
Merge remote-tracking branch 'origin/feat/proxy-shutdown-broadcast-an…
TheBjoRedCraft dccb0b9
feat: improve error logging and fix variable naming inconsistencies
TheBjoRedCraft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...surf-core-api-common/src/main/kotlin/dev/slne/surf/core/api/common/error/SurfCoreError.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package dev.slne.surf.core.api.common.error | ||
|
|
||
| import java.time.OffsetDateTime | ||
| import java.util.* | ||
|
|
||
| data class SurfCoreError( | ||
| val playerUuid: UUID, | ||
| val code: String, | ||
| val message: String, | ||
| val server: String, | ||
| val timestamp: OffsetDateTime | ||
| ) |
18 changes: 18 additions & 0 deletions
18
...ore-api-common/src/main/kotlin/dev/slne/surf/core/api/common/error/SurfCoreErrorFilter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package dev.slne.surf.core.api.common.error | ||
|
|
||
| import java.time.OffsetDateTime | ||
| import java.util.* | ||
|
|
||
| data class SurfCoreErrorFilter( | ||
| val playerUuid: UUID? = null, | ||
| val code: String? = null, | ||
| val messageLike: String? = null, | ||
| val server: String? = null, | ||
| val timestampAfter: OffsetDateTime? = null, | ||
| val timestampBefore: OffsetDateTime? = null, | ||
| val limit: Int = 50 | ||
| ) { | ||
| companion object { | ||
| fun empty() = SurfCoreErrorFilter() | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
...ore-api-common/src/main/kotlin/dev/slne/surf/core/api/common/error/SurfCoreSystemError.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package dev.slne.surf.core.api.common.error | ||
|
|
||
| import java.time.OffsetDateTime | ||
| import java.util.* | ||
|
|
||
| data class SurfCoreSystemError( | ||
| val uuid: UUID, | ||
| val errorCode: String, | ||
| val errorMessage: String, | ||
| val stacktrace: String, | ||
| val location: String, | ||
| val server: String, | ||
| val firstOccurred: OffsetDateTime, | ||
| val lastOccurred: OffsetDateTime, | ||
| val occurrenceCount: Int | ||
| ) { | ||
| fun getLocationClassName(): String = | ||
| location | ||
| .substringBefore(':') | ||
| .substringBeforeLast('.') | ||
| .substringAfterLast('.') | ||
| .substringBefore('$') | ||
|
|
||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
...i-common/src/main/kotlin/dev/slne/surf/core/api/common/error/SurfCoreSystemErrorFilter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package dev.slne.surf.core.api.common.error | ||
|
|
||
| import java.time.OffsetDateTime | ||
| import java.util.* | ||
|
|
||
| data class SurfCoreSystemErrorFilter( | ||
| val uuid: UUID? = null, | ||
| val errorCode: String? = null, | ||
| val messageLike: String? = null, | ||
| val locationLike: String? = null, | ||
| val server: String? = null, | ||
| val firstOccurredAfter: OffsetDateTime? = null, | ||
| val firstOccurredBefore: OffsetDateTime? = null, | ||
| val lastOccurredAfter: OffsetDateTime? = null, | ||
| val lastOccurredBefore: OffsetDateTime? = null, | ||
| val minOccurrenceCount: Int? = null, | ||
| val limit: Int = 50 | ||
| ) { | ||
| companion object { | ||
| fun empty() = SurfCoreSystemErrorFilter() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
.../src/main/kotlin/dev/slne/surf/core/fallback/repository/SurfCoreErrorLoggingRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package dev.slne.surf.core.fallback.repository | ||
|
|
||
| import dev.slne.surf.core.api.common.error.SurfCoreError | ||
| import dev.slne.surf.core.api.common.error.SurfCoreErrorFilter | ||
| import dev.slne.surf.core.fallback.table.SurfCoreErrorLogsTable | ||
| import dev.slne.surf.database.libs.org.jetbrains.exposed.v1.core.* | ||
| import dev.slne.surf.database.libs.org.jetbrains.exposed.v1.r2dbc.insert | ||
| import dev.slne.surf.database.libs.org.jetbrains.exposed.v1.r2dbc.selectAll | ||
| import dev.slne.surf.database.libs.org.jetbrains.exposed.v1.r2dbc.transactions.suspendTransaction | ||
| import dev.slne.surf.surfapi.core.api.util.toObjectList | ||
| import it.unimi.dsi.fastutil.objects.ObjectList | ||
| import kotlinx.coroutines.flow.firstOrNull | ||
| import kotlinx.coroutines.flow.map | ||
| import kotlinx.coroutines.flow.toList | ||
| import java.time.OffsetDateTime | ||
| import java.util.* | ||
|
|
||
| val surfCoreErrorLoggingRepository = SurfCoreErrorLoggingRepository() | ||
|
|
||
| class SurfCoreErrorLoggingRepository { | ||
| suspend fun logError( | ||
| playerUuid: UUID, | ||
| code: String, | ||
| message: String, | ||
| server: String, | ||
| ): SurfCoreError = suspendTransaction { | ||
| val timestamp = OffsetDateTime.now() | ||
| SurfCoreErrorLogsTable.insert { | ||
| it[SurfCoreErrorLogsTable.playerUuid] = playerUuid | ||
| it[SurfCoreErrorLogsTable.errorCode] = code | ||
| it[SurfCoreErrorLogsTable.errorMessage] = message | ||
| it[SurfCoreErrorLogsTable.server] = server | ||
| it[SurfCoreErrorLogsTable.timestamp] = timestamp | ||
| } | ||
|
|
||
| SurfCoreError(playerUuid, code, message, server, timestamp) | ||
| } | ||
|
|
||
| suspend fun getErrors(playerUuid: UUID): ObjectList<SurfCoreError> = suspendTransaction { | ||
| SurfCoreErrorLogsTable.selectAll().where(SurfCoreErrorLogsTable.playerUuid eq playerUuid) | ||
| .map { | ||
| SurfCoreError( | ||
| playerUuid = it[SurfCoreErrorLogsTable.playerUuid], | ||
| code = it[SurfCoreErrorLogsTable.errorCode], | ||
| message = it[SurfCoreErrorLogsTable.errorMessage], | ||
| server = it[SurfCoreErrorLogsTable.server], | ||
| timestamp = it[SurfCoreErrorLogsTable.timestamp] | ||
| ) | ||
| }.toList().toObjectList() | ||
| } | ||
|
|
||
| suspend fun getErrors(filter: SurfCoreErrorFilter): ObjectList<SurfCoreError> = | ||
| suspendTransaction { | ||
| var query = SurfCoreErrorLogsTable.selectAll() | ||
|
|
||
| var whereCondition: Op<Boolean>? = | ||
| filter.playerUuid?.let { SurfCoreErrorLogsTable.playerUuid eq it } | ||
|
|
||
| filter.code?.let { | ||
| whereCondition = whereCondition.andCondition(SurfCoreErrorLogsTable.errorCode eq it) | ||
| } | ||
|
|
||
| filter.messageLike?.let { | ||
| whereCondition = | ||
| whereCondition.andCondition(SurfCoreErrorLogsTable.errorMessage like "%$it%") | ||
| } | ||
|
|
||
| filter.server?.let { | ||
| whereCondition = whereCondition.andCondition(SurfCoreErrorLogsTable.server eq it) | ||
| } | ||
|
|
||
| filter.timestampAfter?.let { | ||
| whereCondition = | ||
| whereCondition.andCondition(SurfCoreErrorLogsTable.timestamp greaterEq it) | ||
| } | ||
|
|
||
| filter.timestampBefore?.let { | ||
| whereCondition = | ||
| whereCondition.andCondition(SurfCoreErrorLogsTable.timestamp lessEq it) | ||
| } | ||
|
|
||
| whereCondition?.let { query = query.where(it) } | ||
|
|
||
| query | ||
| .limit(filter.limit) | ||
| .map { | ||
| SurfCoreError( | ||
| playerUuid = it[SurfCoreErrorLogsTable.playerUuid], | ||
| code = it[SurfCoreErrorLogsTable.errorCode], | ||
| message = it[SurfCoreErrorLogsTable.errorMessage], | ||
| server = it[SurfCoreErrorLogsTable.server], | ||
| timestamp = it[SurfCoreErrorLogsTable.timestamp] | ||
| ) | ||
| }.toList().toObjectList() | ||
| } | ||
|
|
||
| suspend fun getError(code: String): SurfCoreError? = suspendTransaction { | ||
| SurfCoreErrorLogsTable.selectAll().where(SurfCoreErrorLogsTable.errorCode eq code).map { | ||
| SurfCoreError( | ||
| playerUuid = it[SurfCoreErrorLogsTable.playerUuid], | ||
| code = it[SurfCoreErrorLogsTable.errorCode], | ||
| message = it[SurfCoreErrorLogsTable.errorMessage], | ||
| server = it[SurfCoreErrorLogsTable.server], | ||
| timestamp = it[SurfCoreErrorLogsTable.timestamp] | ||
| ) | ||
| }.firstOrNull() | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getError(code)assumeserror_codeuniquely identifies a single player error log, but the table schema does not enforce uniqueness onerror_code. Even if collisions are rare, this can return the wrong player's error. Either enforce uniqueness at the DB level (and retry on conflict when generating codes) or change the lookup API to include a disambiguator (e.g., player UUID + code, or code + timestamp).