lunatic
lunatic copied to clipboard
Print process name in log messages
When processes fail, a message is printed with the process ID:
[2022-08-16T11:48:48Z WARN lunatic_process] Process 4 failed, notifying: 1 links
It would be a nice addition to include the registered name (if available) in the log message:
[2022-08-16T11:48:48Z WARN lunatic_process] Process 4 ("MyProcess") failed, notifying: 1 links
Abstract processes and supervisors could default to using std::any::type_name() if it's not already registed.
This helps with debugging quite a lot, since process id can be quite vague. For even more debugging information, we could provide the line number & module name where an unregistered process was spawned from.
I started looking into this, and currently a process registered under the name of "foo" has other information attached, causing the log to look like:
[2022-09-19T06:36:41Z WARN lunatic_process] Process foo + Process + ()/lunatic::serializer::Bincode failed, notifying: 0 links
I wonder if it's worth adding another parameter to the registry api for a "display name".
So the registry stores: DashMap<String, (u64, u64, String)>, where the key is the usual ID, and the 3rd item in the tuple is a display name (which is the same as what the user registered as).
Any thoughts on this?
The additional information is there for type safety in Rust. If you look up a process, you need to provide a type and it needs to match the registered one. Right now we do it by stringifying the type and attaching it after the name with a + in between.
We could just use a convention here to not overcomplicate things. For example, everything after a + is not displayed.
That sounds like it could work just fine actually. Though if a process has a + in the name then it might cause problems, but it should be okay I think
Yes, I randomly picked +, but we could use something else less common in lunatic-rs. I'm open for suggestions. I think we should also remove the space in between the name and the delimiter to make printing easier.
Then we just add in the registry::* function docs that the rest of the name after ? will not be displayed as part of the log.