limit logging

This commit is contained in:
Milos Kozak 2021-11-11 17:26:19 +01:00
parent 175926527c
commit 51c6237d02

View file

@ -28,20 +28,22 @@ class StorageConstraintPlugin @Inject constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rh: ResourceHelper, rh: ResourceHelper,
private val rxBus: RxBus private val rxBus: RxBus
) : PluginBase(PluginDescription() ) : PluginBase(
.mainType(PluginType.CONSTRAINTS) PluginDescription()
.neverVisible(true) .mainType(PluginType.CONSTRAINTS)
.alwaysEnabled(true) .neverVisible(true)
.showInList(false) .alwaysEnabled(true)
.pluginName(R.string.storage), .showInList(false)
.pluginName(R.string.storage),
aapsLogger, rh, injector aapsLogger, rh, injector
), Constraints { ), Constraints {
@Suppress("ReplaceGetOrSet")
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
val diskFree = availableInternalMemorySize() val diskFree = availableInternalMemorySize()
aapsLogger.debug(LTag.CONSTRAINTS, "Internal storage free (Mb):$diskFree")
if (diskFree < Constants.MINIMUM_FREE_SPACE) { if (diskFree < Constants.MINIMUM_FREE_SPACE) {
value[aapsLogger, false, rh.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE)] = this aapsLogger.debug(LTag.CONSTRAINTS, "Internal storage free (Mb):$diskFree")
value.set(aapsLogger, false, rh.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), this)
val notification = Notification(Notification.DISK_FULL, rh.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL) val notification = Notification(Notification.DISK_FULL, rh.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL)
rxBus.send(EventNewNotification(notification)) rxBus.send(EventNewNotification(notification))
} else { } else {