I like having a short filename option, but I don’t consider it to be particularly important.
I think the “filename (module)” is a bad idea. While the proposal states that this format could be changed later as needed, the reality is that many times people will be parsing the module name and using it in some non-user-output sort of way.
If we do choose that sort of convention, then the format should be described in the Swift documentation.
If we want to expose the module name (a good idea!), something like this makes more sense:
#filename — the short filename
#filepath— the full absolute path to the file
#module — the name of the module
It would be great to have something which gives the equivalent of String(describing: type(of: self))).
I think the best solution is to deprecate #file and create a #context, which resolves to a struct containing the relevant fields.
The #context struct could have a nice CustomStringConvertible that returns a nice summary in whatever format which is suitable for debugging purposes.
This keeps things nice and clean and avoids polluting the namespace with an ever-growing number of #names.
This would also make it simple and give a consistent place to add future info, if needed.
If we change the current behavior of #file or deprecate it, the full path behavior should be made available another way, such as #filePath, or maybe #context.absolutePath.
While these will all be breaking changes for some small number of users, I don’t think that is too relevant, as it would be pretty trivial to search and race #file to #filePath or whatever.
One concern — would moving everything into a struct necessitate including that full path information in the binary, even if that field is not referenced anywhere? Perhaps someone can speak to this.
If that is the case, then I’d prefer leaving the full path available as a special case outside of the #context struct.
Overall I think the change will be good, and some variation of this proposal should be adopted.
I would really like a solution to replace “ String(describing: type(of: self)))” with something that gives a similar result.
I’ve got many projects that have that text in there hundreds of time. Unlike #file, for example, you can’t put that as a default argument to a logging function and have it be useful.