eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.6k stars 373 forks source link

Enhance Logger #1755

Open elBoberido opened 1 year ago

elBoberido commented 1 year ago

Brief feature description

Enhance the basic logger implementation from #1345

Detailed information

elBoberido commented 10 months ago

I think I found a nice way to restore lazy evaluation. catch2 has something like INFO("foo" << 42);. We could do something similar with iceoryx, e.g. IOX_LOG(INFO, "foo" << 42);. Something like IOX_LOG(INFO << "foo" << 42); would be nicer but then lazy evaluation would again become a challenge.

@mossmaurice @MatthiasKillat @FerdinandSpitzschnueffler @dkroenke @elfenpiff what do you think. If you like the idea it should be done before the v3 release since the current logger API was not part of any release and would therefore also not be a breaking change if we apply the proposal.

The macro would basically look like

void force_semicolon(){};

#define IOX_LOG(level, msg_stream)         \
    if (shouldLog(level))                  \
    {                                      \
        LogStream(...) << msg_stream       \
    }                                      \
    force_semicolon()
FerdinandSpitzschnueffler commented 10 months ago

@elBoberido I like the idea. Would you have time to work on it?

elfenpiff commented 10 months ago

@elBoberido I am also a fan of the idea. If you have time, go for it!

elBoberido commented 10 months ago

@FerdinandSpitzschnueffler I don't really have time but my friends find, sed and regex will lend me a hand and in the end reviewing will be more time consuming than the actual change :)