lunatic icon indicating copy to clipboard operation
lunatic copied to clipboard

Print process name in log messages

Open tqwewe opened this issue 3 years ago • 1 comments

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.

tqwewe avatar Aug 16 '22 11:08 tqwewe

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?

tqwewe avatar Sep 19 '22 06:09 tqwewe

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.

bkolobara avatar Sep 28 '22 11:09 bkolobara

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

tqwewe avatar Sep 29 '22 07:09 tqwewe

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.

bkolobara avatar Sep 29 '22 08:09 bkolobara