Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create documentation and examples of logging custom inbound requests #39

Open
petenelson opened this issue Jul 7, 2015 · 8 comments
Open

Comments

@petenelson
Copy link
Owner

for handling inbound web/API calls that are not handled via the WP REST API

@petenelson petenelson changed the title create documentation an examples of logging custom inbound requests create documentation and examples of logging custom inbound requests Jul 7, 2015
@swashata
Copy link

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 :)

@petenelson
Copy link
Owner Author

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.

@swashata
Copy link

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 ?

@petenelson
Copy link
Owner Author

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.

@swashata
Copy link

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).

@petenelson
Copy link
Owner Author

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.

@shiroamada
Copy link

May I confirm that if I using this https://www.npmjs.com/package/wordpress to push to wordpress also won't be log?

@petenelson
Copy link
Owner Author

@shiroamada looks like that uses XML RPC, which would not be logged by the REST API Log plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants