korken89 / smlang-rs

A State Machine Language DSL procedual macro for Rust
Apache License 2.0
192 stars 28 forks source link

Add hooks for logging events, guards, actions, and state transitions #68

Closed mhammerly closed 3 months ago

mhammerly commented 3 months ago

Boost.SML allows a user to provide a type which defines log_process_event(), log_guard(), log_action(), and log_state_change() functions that it'll call at the appropriate times (docs). This PR builds something comparable for smlang-rs and exhibits its usage in examples/state_machine_logger.rs.

It's not an exact match with Boost.SML's:

The deviations in this PR were to work around partial moves of state/event data. For example, partially moving data from the originating state into an action can be a prerequisite for creating the destination state. There wasn't an obvious way for log_state_change() to simultaneously access both. The example shows how this design can still be workable. It scratches my itch, anyway.

mhammerly commented 3 months ago

also do you have plans to push a release sometime soon? there looks to be some good stuff in the commit history since the last release at the end of 2022

ryan-summers commented 3 months ago

I'd be happy to publish a release if desired :) It indeed has been quite a while.

mhammerly commented 3 months ago

changelog entry added!

re a release, including from git is fine for my project and i would feel bad nudging for a big release if it resulted in a bunch of new issues you don't have bandwidth for lol. but i imagine users who aren't watching the github would be pleased to see these unreleased features whenever you find a good time

naturally if there are any problems related to this please @ me and i'll try to help

ryan-summers commented 3 months ago

I'll merge and and release this tomorrow morning when I'm back in the office. Thanks!