-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): record important activities in audit log table (#1518)
- Loading branch information
1 parent
b8aec2c
commit bad7279
Showing
7 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
backend/src/main/kotlin/org/loculus/backend/log/AuditLogTable.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,14 @@ | ||
package org.loculus.backend.log | ||
|
||
import org.jetbrains.exposed.sql.Table | ||
import org.jetbrains.exposed.sql.kotlin.datetime.datetime | ||
|
||
const val AUDIT_LOG_TABLE_NAME = "audit_log" | ||
|
||
object AuditLogTable : Table(AUDIT_LOG_TABLE_NAME) { | ||
|
||
val idColumn = long("id") | ||
val usernameColumn = text("username").nullable() | ||
val timestampColumn = datetime("timestamp") | ||
val descriptionColumn = text("description") | ||
} |
23 changes: 23 additions & 0 deletions
23
backend/src/main/kotlin/org/loculus/backend/log/AuditLogger.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,23 @@ | ||
package org.loculus.backend.log | ||
|
||
import org.jetbrains.exposed.sql.insert | ||
import org.springframework.stereotype.Component | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Component | ||
@Transactional | ||
class AuditLogger { | ||
|
||
fun log(description: String) { | ||
AuditLogTable.insert { | ||
it[descriptionColumn] = description | ||
} | ||
} | ||
|
||
fun log(username: String, description: String) { | ||
AuditLogTable.insert { | ||
it[usernameColumn] = username | ||
it[descriptionColumn] = description | ||
} | ||
} | ||
} |
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
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