Reputation: 383
I'd like to create a log file which is named after the originally run Julia file, for example here julia foo.jl
I'd want foo.jl
. From within a Julia session how can I get this information>
Upvotes: 1
Views: 38
Reputation: 383
This can be done by inspecting the stack
# first get the top of the stack
f = stacktrace()[1]
# then get the file's name as a string, note the is absolute.
abs_filename = String(f.file)
println(abs_filename)
# to get only the filename use
println(basename(abs_filename))
Upvotes: -1