Hi Pranas, to add on more information, in line with your original request,
Splitting this function up into smaller chunks, and noting that .u.L has been initialised on the call to .u.tick.
if[not type key L::`$(-10_string L),string x;.[L;();:;()]]
The logfile name is a combination of the src parameter and the date the logfile is relevant to.
A string representation of a date is 10 chars in length. This portion of code, updates the date portion of the logfile name, using the input argument, checks to see if that file exists using key
and, if it doesn’t, then creates an empty kdb log file with that name using .[L;();:;()]]
i::j::-11!(-2;L);
This portion creates two counter variables (one of which is used when the TP is run in batch mode) that tracks the number of updates in the log file and un-published.
These are used by clients to “recover” from the log file. The -11!(2;L) calculates the number of updates in an existing logfile. Usually this will be zero, but on an intra-day restart this may not be the case.
if[0<=type i;-2 (string L)," is a corrupt log. Truncate to length “,(string last i),” and restart";exit 1]
If i is positive, an issue exists with the log. The TP simply exists.
hopen L
Finally a handle to the logfile is opened, and is the functions return, which is assigned to .u.l. This is used by other functions to append to the log.