Marc Reichelt
03/03/2022, 5:02 PMThrowable()
, to only get the file / class name (performance issues)
• or: using reified
to get the class name (will print weird log tags when scope changes (e.g. it will print CoroutineScope
in some instances))ephemient
03/03/2022, 5:04 PMSam
03/03/2022, 5:04 PMjavaClass.protectionDomain.codeSource.location
(maybe. I haven't tested it 😁)Sam
03/03/2022, 5:15 PM.jar
I expect it'll be even less helpful.Marc Reichelt
03/03/2022, 5:16 PMMarc Reichelt
03/03/2022, 5:17 PMprivate const val TAG = "SomeClass"
at the beginning of the file, and reference it in all log calls. Because that at least does not have a performance drawback, or even printing the wrong tag (we have to pass it manual though).Fleshgrinder
03/03/2022, 5:42 PMFleshgrinder
03/03/2022, 5:42 PMephemient
03/03/2022, 6:08 PMVijay
03/03/2022, 7:50 PM"${obj.javaClass.packageName}.${obj.javaClass.name}"
ephemient
03/03/2022, 10:30 PMjavaClass
has same issue as reified
in the original message: "will print weird log tags when scope changes (e.g. it will print CoroutineScope
in some instances)"Marc Reichelt
03/04/2022, 4:06 PMMarc Reichelt
03/04/2022, 4:07 PMMarc Reichelt
03/04/2022, 4:08 PMMarc Reichelt
03/04/2022, 4:12 PMThrowable()
.
Also, the Android tests very often failed with errors like java.lang.OutOfMemoryError: Failed to allocate a 16 byte allocation with 2572768 free bytes and 2512KB until OOM, target footprint 268435456, growth limit 268435456; giving up on allocation because <1% of heap free after GC.
- because it seems the Throwable().stackTrace
will not be GC’ed correctly (maybe because the implementation is native?), and the memory seems to be to become too fragmented to be cleaned up.
So this will not only gain performance for us, but it will actually fix some weird OutOfMemoryError we saw when the app is used for longer time.nkiesel
03/04/2022, 6:51 PMprivate val logger = mu.KotlinLogging.logger {}
as the first statement after imports. But I also dreamed for a long time about a compiler plugin which would effectively convert a `logger.warn { "Bring a towel!" }`into a logger.warn(file = "Foo.kt", line=123) { "Bring a towel!" }
janvladimirmostert
03/04/2022, 10:32 PMFleshgrinder
03/05/2022, 9:41 AMjanvladimirmostert
03/05/2022, 6:49 PM