Skip to content

Commit 014b1f8

Browse files
committed
refactored "ifStoppedLogAlertAndAlertdescription"
1 parent 4c4662b commit 014b1f8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/kotlin/de/gmuth/ipp/client/IppPrinter.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,32 @@ open class IppPrinter(
8686
} else if (attributes.isEmpty()) {
8787
try {
8888
updateAttributes(requestedAttributesOnInit)
89-
if (isStopped()) {
90-
logger.fine { toString() }
91-
alert?.let { logger.info { "alert: $it" } }
92-
alertDescription?.let { logger.info { "alert-description: $it" } }
93-
}
89+
ifStoppedLogAlertAndAlertdescription()
9490
} catch (ippOperationException: IppOperationException) {
9591
if (ippOperationException.statusIs(ClientErrorNotFound))
9692
logger.severe { ippOperationException.message }
9793
else {
9894
logger.severe { "Failed to get printer attributes on init. Workaround: getPrinterAttributesOnInit=false" }
9995
ippOperationException.response.apply {
10096
logger.warning { toString() } // IppClient logs request and response
101-
if (containsGroup(Printer)) logger.warning { "${printerGroup.size} attributes parsed" }
97+
if (containsGroup(Printer)) logger.warning { "${printerGroup.size} printer attributes parsed" }
10298
}
10399
}
104100
throw ippOperationException
105101
}
106102
}
107-
initPrinterDirectory()
103+
configurePrinterDirectory()
104+
}
105+
106+
fun ifStoppedLogAlertAndAlertdescription() {
107+
if (isStopped()) {
108+
logger.fine { toString() }
109+
alert?.let { logger.info { "alert: $it" } }
110+
alertDescription?.let { logger.info { "alert-description: $it" } }
111+
}
108112
}
109113

110-
private fun initPrinterDirectory() {
114+
private fun configurePrinterDirectory() {
111115
printerDirectory =
112116
if (attributes.isEmpty()) createTempDirectory()
113117
else Path.of((if (isCups()) "CUPS_" else "") + makeAndModel.text.replace("\\s+".toRegex(), "_"))

0 commit comments

Comments
 (0)