cancel
Showing results for 
Search instead for 
Did you mean: 

Script help

subhash_a_chand
New Contributor

Hello All,
There is log file writting during execution of SnapLogic pipeline, as we dont have direct access
so wanted to browse below directory from script snap.

Can anyone help me here.

Below is the javascript used for writ the logs:-

try { load(“nashorn:mozilla_compat.js”); } catch (e) { }

var impl = {

input: input,
output: output,
error: error,
log: log,

execute: function () {
    while (this.input.hasNext()) {
        var doc = this.input.next();
        this.output.write(doc, doc.response);

        var lastSystemTime = doc.lastSystemTime;

        var wrapper = new java.util.HashMap();
        wrapper.putAll(doc);
        wrapper.remove("lastSystemTime");
        
        var externalSystem = wrapper.externalSystem;

        if ((externalSystem != null) && (externalSystem.length > 0)) {
            if (! externalSystem[externalSystem.length - 1].endTime) {
                externalSystem[externalSystem.length - 1].endTime = lastSystemTime;
            }
        }

        wrapper.put("success", false);

        try {
            var om = new ObjectMapper();
            om.writeValue(new java.io.File("/tmp/API_LOG/" + doc.executionId), wrapper);
        } catch (e) {}
    }
}

};

importPackage(com.snaplogic.scripting.language);
importPackage(java.util.HashMap);
importPackage(“com.fasterxml.jackson.databind”);
importPackage(java.io.File);
var hook = new com.snaplogic.scripting.language.ScriptHook(impl);

Can any onne help me here to read above directory or files ??

Thanks in advanced.

2 REPLIES 2

robin
Former Employee

@subhash.a.chandra I believe your question is you wish to browse the /tmp/API_LOG/ directory which contains the log files you are writing via the Script Snap, is that correct?

The Binary Snap Pack has a Directory Browser and File Reader Snaps that can work with the local filesystem e.g. file:///tmp/API_LOG/ - is that something you have tried?

Thanks robin for your suggetion.

I have tried that I was able to access files.
But still I wanted to access from script if something you have that will be good.