wp-rest-api-log
wp-rest-api-log copied to clipboard
create documentation and examples of logging custom inbound requests
for handling inbound web/API calls that are not handled via the WP REST API
Hello,
I am interested in using this plugin. For this issue, is it already implemented or does it needs to be implemented? If it needs to be implemented, then perhaps I can be of help :)
It needs to be implemented, but it should probably wait until beta 2 is released in the near future as it may have some updates to the actions and filters used for logging requests.
I checked with the beta 1 version and it logged a custom request on URL /wp-json/ipt-api/v1/fsqm/
(This is just something I have developed for my envato plugins). So I think I was confused with the topic. You are probably talking about custom REST API implementation that doesn't do a register_rest_route
?
Yeah, it technically has the ability to log requests that aren't going through the core REST API functions. For example, say you were doing a wp_remote_get() from your server to another server, you could manually log the request and response by doing do_action( 'wp-rest-api-log-insert', $args )
and passing it an array of data in the expected format. The source code has more details: https://github.com/petenelson/wp-rest-api-log/blob/master/includes/class-wp-rest-api-log.php#L37
Thinking about this more, I'll probably want to pass some sort of context (probably a taxonomy) as to where the request/response came from... whether it's from the REST API or something logged outside of the REST API.
I got it. So this system has the ability to log both inbound and outbound requests.
Also I see that the logging happens through the post table and custom post type. Any particular reason behind using this approach? Would it not had been better to use a different table? (In terms of performance, not jamming up the post table etc).
The version in the WordPress repo uses custom tables, but this beta version moves away from those into the posts table. Performance is a concern, but it was easier to use WP_Query to get records vs writing tons of custom SQL statements to search for records. I'll be adding an automatic process to purge old log records to hopefully keep down the impact on the posts table, as well as an admin settings page to be able to turn logging on and off as-needed.
May I confirm that if I using this https://www.npmjs.com/package/wordpress to push to wordpress also won't be log?
@shiroamada looks like that uses XML RPC, which would not be logged by the REST API Log plugin.