I want to know how many times a media url is accessed and the ip address used, in order that I can disable the link if it is being used too many times from too many locations.
I have an app where a user can log in and get a unique download link for a media object/file that they will use in another third party desktop app. The third party app will download the file on a set schedule.
If I can see the access logs for the url I can identify where users are sharing the file with other people in other locations which is against the licence.
Is the data I require available anywhere within Anvil?
You can also store your URL in a table, with a timestamp and a simple object column.
Access this table through a server module and you can use anvil.server.context.client to gather data about the requester. If it were me I would mash a bunch of that data together in a hash function and add it as a string to a set in the simple object column on every request.
If either the timestamp becomes too old, or the len() of your simple object column for that URL row grows too large, the URL can be deleted from the table and the client can be prevented from getting the download link.
See the following examples of the use of context.client:
You can create your own log on a table as suggested by @ianb, or you can just print('something') and you will see it on the app log. You can add whatever you want to the app log.
Unfortunately the text search on the logs had been improved and was working very very well, but now it has been broken for a while.