I have a few suggestions.
First I just wanted to clarify when exactly you want to log this information.
Do you only want to log this information when run from the action in the Browser, or do you want to capture this information whenever folder creation is run.
Since folder creation can be ran automatically during certain processes like launching software or saving a file, user’s may end up creating folder without even realising they are.
If you wanted to only catch it when folder creation is run as an action, then I would recomend taking over the
tk-shotgun-folders which is the app that runs the action from the browser. Usually I wouldn’t recommend taking over an app unless you have to, but it’s not a very complicated app, and we don’t updated it very frequently.
If you want to capture the logging whenever folder creation is run, then I think the
process_folder_creation.py hook is probably a good place to do it.
There are a couple of approaches you could use I think, but I’ve not tested.
Grab the context from the engine:
engine = sgtk.platform.current_engine()
user = engine.context.user
However, if you have code that runs the folder creation using the API when an engine isn’t started, then there won’t be an engine, but I think this would probably work for most use cases. Also, the user won’t be in the context if you are using script authentication, and your OS user’s login name doesn’t match your Shotgun user login name.
You could capture the OS user name and try and match it to a Shotgun user?