Skip to content

Commit

Permalink
chore(model): Allow setting the affected path of an issue
Browse files Browse the repository at this point in the history
Extend the extension function to create and log an `Issue` to allow
setting the affected path which causes the issue.

Signed-off-by: Marcel Bochtler <marcel.bochtler@bosch.com>
  • Loading branch information
MarcelBochtler committed Dec 18, 2024
1 parent 83a9a58 commit 8ecb98f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions model/src/main/kotlin/Issue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ class NormalizeLineBreaksSerializer : StdSerializer<String>(String::class.java)
/**
* Create an [Issue] and log the message. The log level is aligned with the [severity].
*/
inline fun <reified T : Any> T.createAndLogIssue(source: String, message: String, severity: Severity? = null): Issue {
val issue = severity?.let { Issue(source = source, message = message, severity = it) }
?: Issue(source = source, message = message)
inline fun <reified T : Any> T.createAndLogIssue(
source: String,
message: String,
severity: Severity? = null,
affectedPath: String? = null
): Issue {
val issue = severity?.let { Issue(source = source, message = message, severity = it, affectedPath = affectedPath) }
?: Issue(source = source, message = message, affectedPath = affectedPath)
logger.log(issue.severity.toLog4jLevel()) { message }
return issue
}

0 comments on commit 8ecb98f

Please sign in to comment.