generated from leanix/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CID-2774: Send error logs to backend
- Loading branch information
1 parent
afcd120
commit a37dbbf
Showing
9 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,23 @@ | ||
package net.leanix.githubagent.dto | ||
|
||
import java.util.UUID | ||
|
||
data class SyncLogDto( | ||
val runId: UUID?, | ||
val trigger: Trigger, | ||
val logLevel: LogLevel, | ||
val message: String | ||
) | ||
|
||
enum class Trigger { | ||
START_FULL_SYNC, | ||
FINISH_FULL_SYNC, | ||
GENERIC | ||
} | ||
|
||
enum class LogLevel { | ||
OK, | ||
WARNING, | ||
INFO, | ||
ERROR | ||
} |
This file contains 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
This file contains 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
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/net/leanix/githubagent/services/SyncLogService.kt
This file contains 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,33 @@ | ||
package net.leanix.githubagent.services | ||
|
||
import net.leanix.githubagent.dto.LogLevel | ||
import net.leanix.githubagent.dto.SyncLogDto | ||
import net.leanix.githubagent.dto.Trigger | ||
import net.leanix.githubagent.shared.LOGS_TOPIC | ||
import org.springframework.stereotype.Service | ||
import java.util.UUID | ||
|
||
@Service | ||
class SyncLogService( | ||
private val webSocketService: WebSocketService, | ||
private val cachingService: CachingService | ||
) { | ||
fun sendErrorLog(message: String) { | ||
sendSyncLog(message, LOGS_TOPIC, null, LogLevel.ERROR) | ||
} | ||
|
||
fun sendSyncLog(message: String, topic: String, trigger: Trigger?, logLevel: LogLevel) { | ||
val runId = cachingService.get("runId") as UUID | ||
val syncLogDto = SyncLogDto( | ||
runId = runId, | ||
trigger = trigger ?: Trigger.GENERIC, | ||
logLevel = logLevel, | ||
message = message | ||
) | ||
webSocketService.sendMessage(constructTopic(topic), syncLogDto) | ||
} | ||
|
||
private fun constructTopic(topic: String): String { | ||
return "${cachingService.get("runId")}/$topic" | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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