ACF Library

Save_Logg

Back to List

Description: Saving logg files in case of application events, or for debugg purposes.

FileMaker Prototype:

Set Variable [$res; ACFU_Save_Logg( string_logg;  string_name)]

Category: BOOTSTRAP

NOTE: The bootstrap library comes preloaded in the plugin. Read more

Function source:

/*

   To save content of log to a file in users document directory. 
   Folder name: ~/Documents/ACFLoggFiles/
    creates directory if it does not exists. 
   Returns Path to logg file, to be used in Append_Logg. 
   Parameters: 
      logg : The content to be written to the logg file. 
      name : The name part of the full fulename as: YYYYmmdd_hhmmss_<name>_logg.txt
   
*/
function Save_Logg ( string logg , string name)
   FunctionID 233; 
   string logdir = documents_directory()+"ACFLoggFiles";  
   string res; 
   if ( ! directory_exists ( logdir )) then
      res = create_directory (logdir ); 
   end if
   logg = substitute ( logg, "\r", "\n"); 
   string path = logdir+format("/%s_%s_logg.txt", string ( now()+3600, "%Y%m%d_%H%M%S"), name); 
   res = delete_file ( path ); 
   int x = open ( path, "w"); 
   if ( isWindows ) then 
      write ( x, substitute ( logg, "\n", "\r\n")); 
   else
      write ( x, logg); 
   end if
   close ( x ); 
   return path; 
end

The Save_Logg function simplifies saving log information from the FileMaker application. It accepts two parameters: the log text, which can be long or short, and the name of the log. A folder named "ACFloggFiles" is created in the user's Documents directory, and a log file with a timestamp and specified name is written to this folder.

Example:

Set Variable [$res; ACFU_Save_Logg( "The report finished with result bla bla"; "reportLogg")]

For example, if you have a loop processing many records, you can accumulate log information in a text variable during each iteration. At the end of the loop, use this function to write the accumulated log information to a file. This allows you to review the log file afterward to confirm that the loop performed as expected.

Back to List