Claim ownership - SchwarzIT/sap-usi-logging-api GitHub Wiki

To claim the ownership (see: Central Concepts -> Loggers have owners) for a logger instance you can simply call the following method.

DATA(token) = logger->claim_ownership( ).

First call

The very first call returns the actual token that will make the caller the owner of the log writer. The token has to be stored, as it will be needed to save and destroy the log later.

Subsequent call

Any subsequent call will return a fake token, that is basically good for nothing. Critical actions like saving or destroying a logger cannot be executed with this object, as it is no legit proof of ownership. There is no possibility to distinguish between the real and a fake token.

This might seem odd at first, but the reason is fairly simle: Just imagine, you integrate the API into e.g. a BAdI, that will run in various applications. Some of them might use this API as well while others might not. If the main application uses this API, then your log messages must become a part of the main applications log (see: Central Concepts -> One Log). This should work automatically - you should not even have to think about this.

Whomever is using this API is supposed to stick to their own business anyway. Snooping on the token would be at least useless, if not even harmful.

Also returning null is a horrible practice ;-)