I'm experimenting with CodeSite Express bundled into Delphi XE. I want to use the Category feature like this:
CodeSite.Category := 'SomeCategory';
CodeSite.EnterMethod ('SomeMethod');
try
DoSomething;
finally
CodeSite.ExitMethod ('SomeMethod');
end;
The problem is that if DoSomething contains logging code as well that sets the category, than the ExitMethod will end up in a different category and will blow up the whole hierarchy in the viewer.
Even worse if threading kicks in: Setting the Category and then invoking log commands is obviously not an atomic operation, so two threads that use CodeSite logging cannot really use the Category. At least that's how it looks like in my logs. I would have expected the Category to be thread-local but it seems not.
What's the right pattern to deal with categories in the context of nested logging and threading?
Thanks!