Skip to content

Commit

Permalink
fix: Add verbose flag in js interface[DHIS2-18247]
Browse files Browse the repository at this point in the history
  • Loading branch information
enricocolasante committed Oct 22, 2024
1 parent 5fa1af7 commit 326c489
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}

version = "3.1.0-SNAPSHOT"
version = "3.2.0-SNAPSHOT"
group = "org.hisp.dhis.rules"

if (project.hasProperty("removeSnapshotSuffix")) {
Expand Down
10 changes: 7 additions & 3 deletions src/jsMain/kotlin/org/hisp/dhis/rules/Logger.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.hisp.dhis.rules

actual fun createLogger(className: String): Logger {
return Logger({message -> println(message)}, {message: String -> println(message)})
}
actual fun createLogger(className: String): Logger =
Logger(
severe = { message -> console.error(message) },
fine = { message ->
if (RuleEngineJs.verbose) console.info(message)
},
)
11 changes: 0 additions & 11 deletions src/jsMain/kotlin/org/hisp/dhis/rules/RuleDataValueJs.kt

This file was deleted.

10 changes: 9 additions & 1 deletion src/jsMain/kotlin/org/hisp/dhis/rules/RuleEngineJs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import org.hisp.dhis.rules.api.RuleEngineContext
import org.hisp.dhis.rules.models.*

@JsExport
class RuleEngineJs {
class RuleEngineJs(verbose: Boolean = false) {
init {
RuleEngineJs.verbose = verbose
}

fun validate(expression: String, dataItemStore: JsMap<String, DataItemJs>): RuleValidationResult{
return RuleEngine.getInstance().validate(expression, toMap(dataItemStore, {it}, ::toDataItemJava))
}
Expand Down Expand Up @@ -190,4 +194,8 @@ class RuleEngineJs {
)
}
}

internal companion object {
var verbose: Boolean = false
}
}

0 comments on commit 326c489

Please sign in to comment.