stream icon indicating copy to clipboard operation
stream copied to clipboard

Consider a "quick log" feature

Open sirjonathan opened this issue 9 years ago • 3 comments

It'd be great to have a way as a developer to really easily write to Stream, without having to register a custom connector, etc.

Could you give us a function (within, perhaps, a "Quick Log" context) that allowed us to write a message to the Stream log? This would be particularly helpful within custom applications where you want different aspects of the application (e.g. "Sequence initiated", "Sequence completed", etc., without having to register each aspect.

sirjonathan avatar Feb 21 '16 15:02 sirjonathan

I have seen an interesting use of a reversed hook used for just this thing. E.g. Stream could create a hook for something like:

add_action( 'wp_stream_quick_log', function( $message, $reason, $plugin, $user ) {
  // create logger object and log the message
}

Other plugins can then trigger this by doing: do_action( 'wp_stream_quick_log', $message, $reason, $plugin, $user );

The passed variables of course will need to be considered. This is just an example of using a hook in reverse to offer an easy way to log to Stream.

rheinardkorf avatar Jul 21 '16 06:07 rheinardkorf

I also would really like to have this feature built into Stream! :-)

vayurobins avatar Mar 15 '17 11:03 vayurobins

@kasparsd I feel there is some merit to this functionality, but also recognize it could be easily abused. While adding a "quick log" would prove useful in some contexts, the ability to log to the Stream table with a simple filter seems like a risky idea.

IMO, if a plugin wants to include some logging system for Stream, extending the connectors it the correct way to do so. What do you think?

kopepasah avatar Jul 07 '20 16:07 kopepasah