Mon Oct 25, 2021 3:15 am
Login Register Lost Password? Contact Us

Automatically Log Function/Macro/Module Calls

Comments and questions related to the Enterprise Control Language

Mon Nov 16, 2015 5:22 pm Change Time Zone

My team wants to automatically log the use of our team's repository function/macro/modules. E.g. when my ECL code calls a module written by a colleague in the repository, one record will be added to the log file recording my user id, time, WUID, etc. The ideal solution is to minimally modify existing repository files so that the users do not need any extra coding, but the log will be automatically updated.

Our current attempt uses a module to update the log (see below). The module will load the current log file, add a new line, output the new log to a temp dir, delete the current log and rename the temp dir to the current dir. This module will be appended to our repository module/functions via a SUCCESS clause.

There are 3 issues with this attempt:
1. the output step generates an output tab in ECL IDE. Is there a way to suppress/hide this output? We want the log to be updated in the background so that the user will not notice it.
2. If a module has 100 EXPORT's, then the developer needs 100 SUCCESS's to generate the
log for each export. Is there a way to force execute a line in the module so that the developer only needs to add 1 line of code, but the log will be executed whenever the module is called?
3. Also, this attempt becomes clumsy as the size of the log file becomes large. Is there a better alternative solution? say using system log file?

Code: Select all
// Module to update log
EXPORT HPCC_Proc_Log(string proc_name) := MODULE
                     lib_timelib.timelib.CurrentTimestamp(TRUE)}],Proc_Log_Rec) +
  EXPORT Proc_Log_Rec := RECORD
    string procedure;
    string user;
    string wuid;
    unsigned4 date;
    unsigned4 time;
    unsigned8 stamp;

// Log function calls
EXPORT string Test(string input) := FUNCTION
  out := input+'_to_output'
      // add one line in log file using module HPCC_Proc_Log
  RETURN out;

Thank you! :)
Posts: 6
Joined: Mon Nov 16, 2015 2:29 pm

Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest