Better debug logs with these improvements

Automatically translated from English

As a 4D developer, you may have already activated the debug log to troubleshoot problems. 4D v17 R5 introduces several improvements to help you analyze these files, such as logging only the current process and logging calls to member methods (collection or object methods).

New selector for process logging

The SET DATABASE PARAMETER command now accepts a new selector, Current process debug log recording. Called from any part of a process, it will start logging just for the current process and create a “4DDebugLog_pX_Y.txt” file in the 4D logs folder (where X is the process PUID and Y the sequence file number). Of course, you can also get the process debug log state using this new selector with the Get database parameter command.

SET DATABASE PARAMETER(Current process debug log recording;2+4+8)

You can continue to use the Debug log recording selector to record logs of the activity of all processes, excluding the processes logged by Current process debug log recording.

Reminder: you can easily access the debug logs using this line of code:

SHOW ON DISK(Get 4D folder(Logs folder))

In the screenshot below, you can see the logs generated by five processes:

Keep in mind that since the SET DATABASE PARAMETER is not thread safe, the process will start in cooperative mode.

member METHODS logging

By default, the debug logs now include calls to member methods. They’re logged with command type number 9. If you don’t want the member methods included, just call the SET DATABASE PARAMETER command and the Debug log recording or Current process debug log recording selectors with a new option which has the value 32. You still can combine the options to obtain the debug logs you want.

This example shows how to log the WiFi and Ethernet interfaces in separate collections:

SET DATABASE PARAMETER(Current process debug log recording;2+4+8)
C_COLLECTION($_networkInterfaces;$_ethernet;$_wifi)
$_networkInterfaces:=Get system info.networkInterfaces
$_ethernet:=$_networkInterfaces.query("type = :1";"ethernet")
$_wifi:=$_networkInterfaces.query("type = :1";"wifi")
SET DATABASE PARAMETER(Current process debug log recording;0)

The code returns: 

More security

Previously when launching logs, files were generated until there was no more disk space available. To avoid errors or accidental activation on the 4D Server Administration Window – which could be dangerous – the number of generated files is limited to 50 by default. You can modify this limit via the SET DATABASE PARAMETER command and the Circular log limitation selector.

// Limit the number of logs files to 100 (the default number is set to 50)
SET DATABASE PARAMETER(Circular log limitation;100)

Avatar

• Product Owner •

Damien Fuzeau has joined the 4D Product team in February 2019. As a Product Owner, he is in charge of writing user stories, then translating them to functional specifications. His job also entails making sure that the feature implementations delivered are meeting the customer needs.

Damien is graduated from the University of Nantes in software engineering. He spent more than 23 years in its former company, first as developer (discovering 4D in 1997), and later as engineering manager and software architect. This company is a 4D OEM partner and deployed 4D based business softwares for thousands users, on hundreds servers. So, Damien is used to 4D development and deployment in a multi-language context.