Is there a way to prevent developers from using ko...
# getting-started
s
Is there a way to prevent developers from using kotlin-logging's logger.log("this $expensiveOperation()"), in favor of them doing logger.log { "this $expensiveOperation()" } ? https://github.com/MicroUtils/kotlin-logging
c
perhaps a detekt rule that flags this?
j
Do you mean a specific
expensiveOperation
? Or any method call? You could write a wrapper for
logger.log
that provides a scope to call the operation only in the lambda form, but that would be a bit convoluted
s
aynthing, just so that they are using the lambda form always
j
ah
s
since the lambda form is the only one that can be optimized out
j
maybe you could go with a custom IDEA inspection that flags all usages of
logger.log(String)
- but that would only work on this IDE. Otherwise yeah a rule on whatever linter you're using would be best
s
hmmm that would work.
are those trivial to add? can you make it auto replace them?
oooh these are nice. i'll read up on them, very powerful
j
Sorry for the delay, I had missed your messages. I'm not sure which solution you're talking about, is it IDEA inspections? Or Detekt? I'm not very well versed in either to be honest, but I know IDEA inspections are pretty nice, especially if you share
.idea
and other devs use IDEA too
s
just intellij inspections. yeah precisely, looks like i can do a lot with them. i'll take a look. thanks
­čĹŹ 1