Logging and Debugging

Logging and debugging is done through the Task object.  A logfile will show up in your Metamerge install directory in the logs subdirectory:  Each run will create a new logfile bearing the name of your assemblylines and a run number.

Key data is logged from the Metamerge Integrator engine, from its components (connectors, parsers, etc.) as well as from user's scripts. Note that almost every connectors has a parameter called "Debug Mode" - with this parameter the user can turn on and off connector's output into the log file.

 

Metamerge Intergrator provides its users with the following "logging/debugging" functionality to use by scripting.

Dumping to the log file is done through the task object. Dumping to the console is done through the main object.

What is provided below is an outline what the user can dump and sample code in JavaScript that performs these operations. All examples show how to dump in the log file. However all you have to do in order to dump to the debugging console is to change the task keyword to main .

1. Dumping the content of an Entry object.

        task.dumpEntry(entry)

        / "main.dump(entry)"  will dump the entry to the debugging console /

 

2. Dumping the content of an Attribute:

    2.1. Dumping single value Attribute:

        Suppose attr (with name Attr1) is the single value attribute you wish to dump. You can create your own attribute and set a value to it with the following 2 lines of code:

    var attr = system.newAttribute("Attr1");
    attr.addValue("Value1");

        - the dumping itself:
        task.logmsg("Dumping single value attribute:" + attr.getName());
        task.logmsg("Value = " + attr.getValue());

    2.1. Dumping multiple values Attribute:

        Suppose attr (with name Attr1) is multiple values attribute you wish to dump. You can create your own attribute and set some values to it with the following 3 lines of code:

    var attr = system.newAttribute("Attr1");
    attr.addValue("Value1");
    attr.addValue("Value2");

        - the dumping itself:
        var values = attr.getValues();
        task.logmsg ("Dumping multiple values Attribute:" + attr.getName());
        for (i=0; i<values.length; i++)
        {
            task.logmsg("Value " + i + " --> " + values[i]);
        }
  
        Hint:  If you don't know apriory whether the attribute is single or multiple values you can use the multiple values pattern - it works even when your attribute is single value.

 

3. Dumping the state of a Connector:

    You can dump (any time) the state of any of the connectors involved in your integration process. The sample code bellow gives you (dumps) all the information available for a particular connector - suppose its name is Conn. Of course, according your needs you can dump arbitrary subset of the connector's parameters listed below.

    var status = Conn.getStats();
    task.logmsg("Dumping Conn status:");

    task.logmsg("Number of add operations performed: " + status.numAdd());
    task.logmsg("Number of delete operations performed: " + status.numDelete());
    task.logmsg("Number of errors: " + status.numErrors());
    task.logmsg("Number of get operations performed: " +  status.numGet());
    task.logmsg("Number of entries ignored: " + status.numIgnored());
    task.logmsg("Number of lookup operations performed: " + status.numLookup());
    task.logmsg("Number of modify operations performed: " + status.numModify());
    task.logmsg("Number of no-change entries: " + status.numNoChange());
    task.logmsg("Number of entries skipped: " + status.numSkipped());

4. Dumping arbitrary log messages:

    We won't surprise you telling you that with the logmsg function you can log any text you want. This means you can indicate (to the log file or to the debugging console) any state of the custom logic of your assembly lines.

    task.logmsg("Type here the message you want to dump");

 



Questions or problems regarding this web site should be directed to webmaster@metamerge.com.
Copyright © 1999-2001 Metamerge AS. All rights reserved.
Last modified: 2001-05-03.