if I have a function at the top level of a file, n...
# getting-started
j
if I have a function at the top level of a file, not inside a class or an object, is there a way to get the name of the file , or the name of the function or if that doesn't work maybe the package ? (would like to log it)
m
Have a look here (though this is mainly for Android): https://kotlinlang.slack.com/archives/C1NNEMDBK/p1581426076010400
s
Something like this maybe:
Copy code
fun func(){
    
}

private val KFunction<*>.fqName: String
    get() = javaMethod!!.declaringClass.name

val foo = ::func.fqName
j
thx guys!
@Mark, I couldn't find a answer to my specific question there. Or did you just want to point me to the logging lib?
m
@jk2018 yes, it was just to say that if you are looking for a logging solution that can include filenames, then that approach might work for you.
j
Got it!, Thx!