Tech Tip: Method to parse project mode conversion log
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: April 18, 2022
When exporting a binary structure to project mode, there may be errors and warnings associated with the project conversion, recorded in the conversion log. It is useful to have a list of each type of error/warning, as well as their counts. The method below parses the conversion log and groups the errors and warnings into text. The text is then saved in a file on disk. The text displays an overview of the amount of each type of error or warning.
C_TEXT($file_t; $verifyLog_t; $message_t; $logParse_t; $msg_t; $count_t) C_OBJECT($json_o; $warnings_o; $errors_o; $msg_o) C_COLLECTION($messages_c) $file_t:=Select document(Get 4D folder(Logs folder); "*"; "List of Logs"; 2) If (OK=1) $verifyLog_t:=Document to text(Document; UTF8 C string) $json_o:=JSON Parse($verifyLog_t) $messages_c:=$json_o.messages $warnings_o:=New object $errors_o:=New object For each ($msg_o; $messages_c) $message_t:=$msg_o.message If ($msg_o.severity="warning") If (Value type($warnings_o[$message_t])=Is undefined) $warnings_o[$message_t]:=1 Else $warnings_o[$message_t]:=$warnings_o[$message_t]+1 End if Else If ($msg_o.severity="error") If (Value type($errors_o[$message_t])=Is undefined) $errors_o[$message_t]:=1 Else $errors_o[$message_t]:=$errors_o[$message_t]+1 End if End if End if End for each End if $logParse_t:="Errors" For each ($msg_t; $errors_o) $count_t:=String($errors_o[$msg_t]) $logParse_t:=$logParse_t+Char(Carriage return)+$msg_t+Char(Tab)+$count_t End for each $logParse_t:=$logParse_t+Char(Carriage return)+Char(Carriage return)+"Warnings" For each ($msg_t; $warnings_o) $count_t:=String($warnings_o[$msg_t]) $logParse_t:=$logParse_t+Char(Carriage return)+$msg_t+Char(Tab)+$count_t End for each TEXT TO DOCUMENT("logParse.txt"; $logParse_t) SHOW ON DISK("logParse.txt") |
After the method is executed, select and open the conversion log from the Logs folder. Then, after the method finishes, the text file will be generated next to the structure file, and its location shown on disk. Example of the result:
Errors
'Background offset' 3D button style is not supported. 18
Unsupported form object type. 2
Warnings
Compatibility setting 'Fields are enterable in dialog boxes' switched on. 1
Compatibility setting 'Radio buttons grouped by name' switched off. 1
The total amount of each type of error or warning will be listed next to its description. In the above example, there are 18 instances of ‘Background offset 3D button’ errors, and 2 instances of ‘Unsupported form object type’ errors. All errors should be addressed when converting a binary application to project application.