can anyone tell me how functions executed in layout window are written to CDS.log file?
I'm not entirely sure I know what answer you are looking for? It is a built-in capability of the tools (not just the layout editor) that the commands, menus, bindkeys etc. that are accessed during a session are recorded in the CDS.log file, and typically the CIW shows a filtered version of what the log file contains (though the filter could be non-restrictive and display everything).
You can print to the CIW using a command such as "printf" and this could be invoked from a menu or bindkey access, either directly as the callback for that menu item or bindkey, or within a procedure that the action calls. Such output would also be captured in the CIW and the CDS.log file.
Does this answer your question?