You are not logged in.
Assuming in a desktop program we have a mORMot server and a bunch of clients.
There will be 2 types of background threads in the program:
A - the server threads started by mORMot server when serving client requests.
B - the other ordinary threads started by the program.
The question is how to distinguish A from B?
I need this info to make sure the mORMot engine will log ONLY errors caused by the engine /db itself, but not errors caused in my other ordinary threads, by utilizing `SQLite3Log.Family.OnBeforeException`.
This is kind of a continued discussion of To allow ignoring exceptions with code, but I decided to post it separately to make things clearer.
Thanks.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Every thread is named.
I have added aThreadName parameter to TSynLogFamily.OnBeforeException callback.
See https://synopse.info/fossil/info/80a92148c9
So you should be able to identify the thread context it runs on by checking the name.
Note that depending on the communication mean used (socket/http.sys/pipe), the thread names won't be the same.
Another (perhaps easier) option may be to define a global boolean threadvar, then set it to true on the withException threads.
Offline
Great! Thanks for your quick reaction, as aways ![]()
But how the mMORMot threads are named? Do they have a fixed prefix or something like that? I did a quick look at the source without a successful finding... Thanks.
Last edited by edwinsn (2018-12-14 14:32:40)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
@ab,
Done as you instructed, see attached screenshot, not sure how to interpret the names...
And I explored the source and found:
constructor TSQLRestThread.Create(aRest: TSQLRest;
aOwnRest, aCreateSuspended: boolean);
begin
...
if fThreadName='' then
FormatUTF8('% %',[self,fRest.Model.Root],fThreadName);
...
end;So is TSQLRestThread.Create where the mORMot server threads are created and named?
Thanks.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Ah yes! Discovered log entries such as "SetThreadName 000026BC=TSQLHttpServer 80/root THttpApiServer". Thanks.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline