web stats
Run Javascript in Channel Context Outside of Mirth - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #11  
Old 06-20-2019, 07:13 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 967
agermano is on a distinguished road
Default

I took inspiration from your Notepad++ solution and set up something similar in vscode. I haven't actually tested this on Windows, but it works on linux.

A note for your config, all of your .\extensions\* entries in the classpath need to be moved up to the parent folder (..\extensions\*)

Also, that debugger is pretty slick. Prior to getting this set up, I had only ever run the shell in interactive mode in a headless environment, so I never tried it to see how it worked.

These are set up as build tasks. Whichever one you configure as the default will run when you press Shift+Ctrl+B.

https://code.visualstudio.com/docs/e...#_custom-tasks

Code:
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run in Rhino shell",
            "type": "process",
            "command": "java",
            "args": [
                "org.mozilla.javascript.tools.shell.Main",
                "-version",
                "200",
                "${file}"
            ],
            "options": {
                "env": {
                    "CLASSPATH": "./*:./commons/*:./database/*:./donkey/*:./javax/*:./jersey/*:./jetty/*:./jms/*:./swagger/*:./javax/jaxb/*:./javax/jaxws/*:./javax/jaxb/ext/*:./javax/jaxws/ext/*:./jersey/ext/*:./jetty/jsp/*:./swagger/ext/*:./custom-lib/*:../extensions/dashboardstatus/*:../extensions/datapruner/*:../extensions/datatype-delimited/*:../extensions/datatype-dicom/*:../extensions/datatype-edi/*:../extensions/datatype-hl7v2/*:../extensions/datatype-hl7v3/*:../extensions/datatype-json/*:../extensions/datatype-ncpdp/*:../extensions/datatype-raw/*:../extensions/datatype-xml/*:../extensions/destinationsetfilter/*:../extensions/dicom/*:../extensions/dicomviewer/*:../extensions/directoryresource/*:../extensions/doc/*:../extensions/extensionmanager/*:../extensions/file/*:../extensions/globalmapviewer/*:../extensions/http/*:../extensions/httpauth/*:../extensions/imageviewer/*:../extensions/javascriptrule/*:../extensions/javascriptstep/*:../extensions/jdbc/*:../extensions/jms/*:../extensions/js/*:../extensions/mapper/*:../extensions/messagebuilder/*:../extensions/mllpmode/*:../extensions/pdfviewer/*:../extensions/rulebuilder/*:../extensions/scriptfilerule/*:../extensions/scriptfilestep/*:../extensions/serverlog/*:../extensions/smtp/*:../extensions/tcp/*:../extensions/textviewer/*:../extensions/vm/*:../extensions/ws/*:../extensions/xsltstep/*:../extensions/dicom/lib/*:../extensions/dicomviewer/lib/*:../extensions/doc/lib/*:../extensions/file/lib/*:../extensions/httpauth/src/*:../extensions/pdfviewer/lib/*:../extensions/ws/lib/*"
                },
                "cwd": "/home/tony/mirth/release/3.7.1/server-lib"
            },
            "windows": {
                "options": {
                    "env": {
                        "CLASSPATH": ".\\*;.\\commons\\*;.\\database\\*;.\\donkey\\*;.\\javax\\*;.\\jersey\\*;.\\jetty\\*;.\\jms\\*;.\\swagger\\*;.\\javax\\jaxb\\*;.\\javax\\jaxws\\*;.\\javax\\jaxb\\ext\\*;.\\javax\\jaxws\\ext\\*;.\\jersey\\ext\\*;.\\jetty\\jsp\\*;.\\swagger\\ext\\*;.\\custom-lib\\*;..\\extensions\\dashboardstatus\\*;..\\extensions\\datapruner\\*;..\\extensions\\datatype-delimited\\*;..\\extensions\\datatype-dicom\\*;..\\extensions\\datatype-edi\\*;..\\extensions\\datatype-hl7v2\\*;..\\extensions\\datatype-hl7v3\\*;..\\extensions\\datatype-json\\*;..\\extensions\\datatype-ncpdp\\*;..\\extensions\\datatype-raw\\*;..\\extensions\\datatype-xml\\*;..\\extensions\\destinationsetfilter\\*;..\\extensions\\dicom\\*;..\\extensions\\dicomviewer\\*;..\\extensions\\directoryresource\\*;..\\extensions\\doc\\*;..\\extensions\\extensionmanager\\*;..\\extensions\\file\\*;..\\extensions\\globalmapviewer\\*;..\\extensions\\http\\*;..\\extensions\\httpauth\\*;..\\extensions\\imageviewer\\*;..\\extensions\\javascriptrule\\*;..\\extensions\\javascriptstep\\*;..\\extensions\\jdbc\\*;..\\extensions\\jms\\*;..\\extensions\\js\\*;..\\extensions\\mapper\\*;..\\extensions\\messagebuilder\\*;..\\extensions\\mllpmode\\*;..\\extensions\\pdfviewer\\*;..\\extensions\\rulebuilder\\*;..\\extensions\\scriptfilerule\\*;..\\extensions\\scriptfilestep\\*;..\\extensions\\serverlog\\*;..\\extensions\\smtp\\*;..\\extensions\\tcp\\*;..\\extensions\\textviewer\\*;..\\extensions\\vm\\*;..\\extensions\\ws\\*;..\\extensions\\xsltstep\\*;..\\extensions\\dicom\\lib\\*;..\\extensions\\dicomviewer\\lib\\*;..\\extensions\\doc\\lib\\*;..\\extensions\\file\\lib\\*;..\\extensions\\httpauth\\src\\*;..\\extensions\\pdfviewer\\lib\\*;..\\extensions\\ws\\lib\\*"
                    },
                    "cwd": "C:\\Program Files\\Mirth Connect\\server-lib"
                }
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Debug in Rhino",
            "type": "process",
            "command": "java",
            "args": [
                "org.mozilla.javascript.tools.debugger.Main",
                "-version",
                "200",
                "${file}"
            ],
            "options": {
                "env": {
                    "CLASSPATH": "./*:./commons/*:./database/*:./donkey/*:./javax/*:./jersey/*:./jetty/*:./jms/*:./swagger/*:./javax/jaxb/*:./javax/jaxws/*:./javax/jaxb/ext/*:./javax/jaxws/ext/*:./jersey/ext/*:./jetty/jsp/*:./swagger/ext/*:./custom-lib/*:../extensions/dashboardstatus/*:../extensions/datapruner/*:../extensions/datatype-delimited/*:../extensions/datatype-dicom/*:../extensions/datatype-edi/*:../extensions/datatype-hl7v2/*:../extensions/datatype-hl7v3/*:../extensions/datatype-json/*:../extensions/datatype-ncpdp/*:../extensions/datatype-raw/*:../extensions/datatype-xml/*:../extensions/destinationsetfilter/*:../extensions/dicom/*:../extensions/dicomviewer/*:../extensions/directoryresource/*:../extensions/doc/*:../extensions/extensionmanager/*:../extensions/file/*:../extensions/globalmapviewer/*:../extensions/http/*:../extensions/httpauth/*:../extensions/imageviewer/*:../extensions/javascriptrule/*:../extensions/javascriptstep/*:../extensions/jdbc/*:../extensions/jms/*:../extensions/js/*:../extensions/mapper/*:../extensions/messagebuilder/*:../extensions/mllpmode/*:../extensions/pdfviewer/*:../extensions/rulebuilder/*:../extensions/scriptfilerule/*:../extensions/scriptfilestep/*:../extensions/serverlog/*:../extensions/smtp/*:../extensions/tcp/*:../extensions/textviewer/*:../extensions/vm/*:../extensions/ws/*:../extensions/xsltstep/*:../extensions/dicom/lib/*:../extensions/dicomviewer/lib/*:../extensions/doc/lib/*:../extensions/file/lib/*:../extensions/httpauth/src/*:../extensions/pdfviewer/lib/*:../extensions/ws/lib/*"
                },
                "cwd": "/home/tony/mirth/release/3.7.1/server-lib"
            },
            "windows": {
                "options": {
                    "env": {
                        "CLASSPATH": ".\\*;.\\commons\\*;.\\database\\*;.\\donkey\\*;.\\javax\\*;.\\jersey\\*;.\\jetty\\*;.\\jms\\*;.\\swagger\\*;.\\javax\\jaxb\\*;.\\javax\\jaxws\\*;.\\javax\\jaxb\\ext\\*;.\\javax\\jaxws\\ext\\*;.\\jersey\\ext\\*;.\\jetty\\jsp\\*;.\\swagger\\ext\\*;.\\custom-lib\\*;..\\extensions\\dashboardstatus\\*;..\\extensions\\datapruner\\*;..\\extensions\\datatype-delimited\\*;..\\extensions\\datatype-dicom\\*;..\\extensions\\datatype-edi\\*;..\\extensions\\datatype-hl7v2\\*;..\\extensions\\datatype-hl7v3\\*;..\\extensions\\datatype-json\\*;..\\extensions\\datatype-ncpdp\\*;..\\extensions\\datatype-raw\\*;..\\extensions\\datatype-xml\\*;..\\extensions\\destinationsetfilter\\*;..\\extensions\\dicom\\*;..\\extensions\\dicomviewer\\*;..\\extensions\\directoryresource\\*;..\\extensions\\doc\\*;..\\extensions\\extensionmanager\\*;..\\extensions\\file\\*;..\\extensions\\globalmapviewer\\*;..\\extensions\\http\\*;..\\extensions\\httpauth\\*;..\\extensions\\imageviewer\\*;..\\extensions\\javascriptrule\\*;..\\extensions\\javascriptstep\\*;..\\extensions\\jdbc\\*;..\\extensions\\jms\\*;..\\extensions\\js\\*;..\\extensions\\mapper\\*;..\\extensions\\messagebuilder\\*;..\\extensions\\mllpmode\\*;..\\extensions\\pdfviewer\\*;..\\extensions\\rulebuilder\\*;..\\extensions\\scriptfilerule\\*;..\\extensions\\scriptfilestep\\*;..\\extensions\\serverlog\\*;..\\extensions\\smtp\\*;..\\extensions\\tcp\\*;..\\extensions\\textviewer\\*;..\\extensions\\vm\\*;..\\extensions\\ws\\*;..\\extensions\\xsltstep\\*;..\\extensions\\dicom\\lib\\*;..\\extensions\\dicomviewer\\lib\\*;..\\extensions\\doc\\lib\\*;..\\extensions\\file\\lib\\*;..\\extensions\\httpauth\\src\\*;..\\extensions\\pdfviewer\\lib\\*;..\\extensions\\ws\\lib\\*"
                    },
                    "cwd": "C:\\Program Files\\Mirth Connect\\server-lib"
                }
            },
            "group": "build"
        }
    ]
}
Reply With Quote
  #12  
Old 06-20-2019, 07:28 PM
Jeff Drumm Jeff Drumm is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 23
Jeff Drumm is on a distinguished road
Default

Thanks for the feedback. Actually, I discovered the classpath issue earlier today and updated the post this evening, but I must have done that some time after you grabbed it.


I don't understand why I can't run a script that creates a database connection object using DatabaseConnectionFactory.createDatabaseConnection (), though. I get the error "js: uncaught JavaScript runtime exception: ReferenceError: "DatabaseConnectionFactory" is not defined."


Any thoughts?


EDIT: Oh, and nice work on the VSCode config!

Last edited by Jeff Drumm; 06-20-2019 at 07:32 PM.
Reply With Quote
  #13  
Old 06-20-2019, 07:36 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 967
agermano is on a distinguished road
Default

Mirth does a lot of setup of the javascript context, adding references to things that won't be available in this environment, importing the User API classes, adding helper functions, etc...


If you add this to the top of your file, you'll get most of the User API.

Code:
importPackage(com.mirth.connect.server.userutil);
Otherwise, you can specify the full path to the class.

Code:
com.mirth.connect.server.userutil.DatabaseConnectionFactory.createDatabaseConnection()
Edit: A third option would be to create a reference to the Rhino JavaClass
Code:
const DatabaseConnectionFactory = com.mirth.connect.server.userutil.DatabaseConnectionFactory;

Last edited by agermano; 06-20-2019 at 07:40 PM.
Reply With Quote
  #14  
Old 06-20-2019, 08:21 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 967
agermano is on a distinguished road
Default

So, you can actually create your own initialization script. I created a new file.

init_rhino.js:
Code:
importPackage(com.mirth.connect.server.userutil);
Then you pass an extra parameter when you launch the shell
Code:
java org.mozilla.javascript.tools.shell.Main -version 200 -e "load('/home/tony/mirth/release/3.7.1/js-lib/init_rhino.js')" %FILE%
The shell executes what you pass in with -e before it starts executing your file.

It doesn't seem to work with the debugger, unfortunately, but you can add the load statement as the first line of your file in either case to setup your default environment instead of passing it as an argument.
Reply With Quote
  #15  
Old 06-21-2019, 02:54 AM
Jeff Drumm Jeff Drumm is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 23
Jeff Drumm is on a distinguished road
Default

Thanks again!

Now if only I can figure out why your suggestion for importPackage() isn't working

Closer, though ... I'm getting the error:
Code:
js: Java class "com.mirth.connect.server.userutil.DatabaseConnectionFactory" has no public instance field or method named "createDatabaseConnection".
now. Seems as though it's finding the class but not the methods ...


EDIT: I also tried specifying the full path to the class and creating a reference with const. Same result

Last edited by Jeff Drumm; 06-21-2019 at 05:24 AM. Reason: other attempts
Reply With Quote
  #16  
Old 06-21-2019, 04:21 AM
Jeff Drumm Jeff Drumm is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 23
Jeff Drumm is on a distinguished road
Default

With NotePad++ I took a different tack with your initialization file idea, and depending on how things work in VSCode you may want to think about implementing something similar since it should also work for the debugger.

Rather than adding an init script to Rhino's execution with -e, I modified the NppExec script as follows:
Code:
npp_console on
set rhinover=200
NPP_SAVE
set tmp=C:\TEMP\ // directory for temporary script
set rhinoinit=C:\etc\rhinoinit.js // initialization file
set rhinotmp=$(tmp)nppExec-$(FILE_NAME) // temporary file name
set cmdline=CMD /C COPY /B "$(rhinoinit)"+"$(FULL_CURRENT_PATH)" "$(rhinotmp)" /Y // build the "create temp copy" command line (w/overwrite)
$(cmdline) // run the command to create the copy
C:\bin\runRhino.cmd shell 200 "$(rhinotmp)" //run rhino run
The debugger script is the same with the exception of the last line, where "shell" is replaced with "debugger."

Sadly, still getting that "no public instance" error, so I'm thinking that more needs to be included in he initialization file ...

Last edited by Jeff Drumm; 06-21-2019 at 05:26 AM. Reason: Useless use of @ removed
Reply With Quote
  #17  
Old 06-21-2019, 06:41 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 967
agermano is on a distinguished road
Default

Nice. I thought about having an extra "compile" step to incorporate the init script as well, but didn't get around to trying it out yet. It was easy enough to just put the load statement at the top of the file. I'm thinking load statements is how "code templates" would be handled, too, so you could control which ones you bring in.

The problem is that you need to create an instance of DatabaseConnectionFactory (the methods aren't static.) Mirth does that for you. The difficult part is that in order to do that you need to pass it a MirthContextFactory, which is very dependent on being in a running Mirth environment. I think it will require implementing a javascript version of DatabaseConnectionFactory that takes some shortcuts to get something that resembles the class from the User API.

Along those lines, here's a drop-in replacement for SerializerFactory I added to my init script. By default it is aware of all of the open source data types (except Raw, because why?) I added an extra method to add commercial or custom types, assuming they are on the classpath. For example, if the hl7v2 type wasn't already present, you could add it like this in your javascript file:
Code:
SerializerFactory.addDataTypeServerPlugin(com.mirth.connect.plugins.datatypes.hl7v2.HL7v2DataTypeServerPlugin);
Edit: Note: None of the deprecated methods are implemented.

SerializerFactory
Code:
var SerializerFactory = (function() {
    var datatypes = com.mirth.connect.plugins.datatypes;
    var dataPluginClasses = [
        datatypes.delimited.DelimitedDataTypeServerPlugin,
        datatypes.dicom.DICOMDataTypeServerPlugin,
        datatypes.edi.EDIDataTypeServerPlugin,
        datatypes.hl7v2.HL7v2DataTypeServerPlugin,
        datatypes.hl7v3.HL7V3DataTypeServerPlugin,
        datatypes.json.JSONDataTypeServerPlugin,
        datatypes.ncpdp.NCPDPDataTypeServerPlugin,
        datatypes.xml.XMLDataTypeServerPlugin
    ];
    var dataPlugins = new org.apache.commons.collections.map.CaseInsensitiveMap(
        dataPluginClasses.reduce(function(obj, javaClass) {
            try {
                var instance = new javaClass();
                obj[instance.getPluginPointName()] = instance;
            }
            catch (e) {}
            return obj;
        }, {})
    );

    function addDataTypeServerPlugin(javaClass) {
        try {
            var instance = new javaClass();
            dataPlugins.put(instance.getPluginPointName(), instance);
        }
        catch (e) {}
    }

    function getSerializer(dataType, serializationPropertiesMap, deserializationPropertiesMap) {
        return (arguments.length === 1)
            ? _getSerializer(dataType, null, null)
            : _getSerializer(dataType, serializationPropertiesMap, deserializationPropertiesMap);
        

        function _getSerializer(dataType, serializationPropertiesMap, deserializationPropertiesMap) {
            var plugin = dataPlugins.get(dataType);
            if (plugin != null) {
                if (serializationPropertiesMap == null) {
                    serializationPropertiesMap = getDefaultSerializationProperties(dataType);
                }
                if (deserializationPropertiesMap == null) {
                    deserializationPropertiesMap = getDefaultDeserializationProperties(dataType);
                }
    
                var properties = plugin.getDefaultProperties().getSerializerProperties();
    
                if (properties.getSerializationProperties() != null) {
                    properties.getSerializationProperties().setProperties(serializationPropertiesMap);
                }
                if (properties.getDeserializationProperties() != null) {
                    properties.getDeserializationProperties().setProperties(deserializationPropertiesMap);
                }
    
                return plugin.getSerializer(properties);
            } else {
                return null;
            }
        }
    }

    function getDefaultSerializationProperties(dataType) {
        var plugin = dataPlugins.get(dataType);
        if (plugin != null && plugin.getDefaultProperties().getSerializationProperties() != null) {
            return plugin.getDefaultProperties().getSerializationProperties().getProperties();
        } else {
            return null;
        }
    }

    function getDefaultDeserializationProperties(dataType) {
        var plugin = dataPlugins.get(dataType);
        if (plugin != null && plugin.getDefaultProperties().getDeserializationProperties() != null) {
            return plugin.getDefaultProperties().getDeserializationProperties().getProperties();
        } else {
            return null;
        }
    }

    return {
        getDefaultSerializationProperties: getDefaultSerializationProperties,
        getDefaultDeserializationProperties: getDefaultDeserializationProperties,
        getSerializer: getSerializer,
        addDataTypeServerPlugin: addDataTypeServerPlugin
    };
})();
SerializerFactory (minified at jscompress.com)
Code:
var SerializerFactory=function(){var e=com.mirth.connect.plugins.datatypes,r=[e.delimited.DelimitedDataTypeServerPlugin,e.dicom.DICOMDataTypeServerPlugin,e.edi.EDIDataTypeServerPlugin,e.hl7v2.HL7v2DataTypeServerPlugin,e.hl7v3.HL7V3DataTypeServerPlugin,e.json.JSONDataTypeServerPlugin,e.ncpdp.NCPDPDataTypeServerPlugin,e.xml.XMLDataTypeServerPlugin],a=new org.apache.commons.collections.map.CaseInsensitiveMap(r.reduce(function(e,r){try{var t=new r;e[t.getPluginPointName()]=t}catch(e){}return e},{}));function l(e){var r=a.get(e);return null!=r&&null!=r.getDefaultProperties().getSerializationProperties()?r.getDefaultProperties().getSerializationProperties().getProperties():null}function o(e){var r=a.get(e);return null!=r&&null!=r.getDefaultProperties().getDeserializationProperties()?r.getDefaultProperties().getDeserializationProperties().getProperties():null}return{getDefaultSerializationProperties:l,getDefaultDeserializationProperties:o,getSerializer:function(e,r,t){return 1===arguments.length?i(e,null,null):i(e,r,t);function i(e,r,t){var i=a.get(e);if(null==i)return null;null==r&&(r=l(e)),null==t&&(t=o(e));var n=i.getDefaultProperties().getSerializerProperties();return null!=n.getSerializationProperties()&&n.getSerializationProperties().setProperties(r),null!=n.getDeserializationProperties()&&n.getDeserializationProperties().setProperties(t),i.getSerializer(n)}},addDataTypeServerPlugin:function(e){try{var r=new e;a.put(r.getPluginPointName(),r)}catch(e){}}}}();

Last edited by agermano; 06-21-2019 at 06:50 AM.
Reply With Quote
  #18  
Old 06-21-2019, 06:59 AM
Jeff Drumm Jeff Drumm is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 23
Jeff Drumm is on a distinguished road
Default

Ah, I was afraid there was some context built that DatabaseConnectionFactory required. Oh well, I guess I'll see what I can come up with for an emulator


Your SerializerFactory will come in handy. Thanks for posting it!
Reply With Quote
  #19  
Old 06-21-2019, 04:51 PM
israelt israelt is offline
What's HL7?
 
Join Date: Jul 2015
Posts: 1
israelt is on a distinguished road
Default

I added an extra build process, that concatenates the three separate files. It's not nice, but it lets me separate some logic. Ideally you would only be modifying main.js or changing out what msg is equal to.

.vcode/tasks.json
Code:
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Concat Files",
            "type": "shell",
            "command": "awk",
            "args": [
                "'{print}'",
                "${workspaceFolder}/init.js",
                "${workspaceFolder}/msg.txt",
                "${workspaceFolder}/main.js",
                ">",
                "${workspaceFolder}/.run.js"
            ]
        },
        {
            "label": "Run in Rhino shell",
            "type": "process",
            "command": "java",
            "args": [
                "org.mozilla.javascript.tools.shell.Main",
                "-version",
                "200",
                "${workspaceFolder}/.run.js"
            ],
            "options": {
                "env": {
                    "CLASSPATH": "./*:./commons/*:./database/*:./donkey/*:./javax/*:./jersey/*:./jetty/*:./jms/*:./swagger/*:./javax/jaxb/*:./javax/jaxws/*:./javax/jaxb/ext/*:./javax/jaxws/ext/*:./jersey/ext/*:./jetty/jsp/*:./swagger/ext/*:./custom-lib/*:../extensions/dashboardstatus/*:../extensions/datapruner/*:../extensions/datatype-delimited/*:../extensions/datatype-dicom/*:../extensions/datatype-edi/*:../extensions/datatype-hl7v2/*:../extensions/datatype-hl7v3/*:../extensions/datatype-json/*:../extensions/datatype-ncpdp/*:../extensions/datatype-raw/*:../extensions/datatype-xml/*:../extensions/destinationsetfilter/*:../extensions/dicom/*:../extensions/dicomviewer/*:../extensions/directoryresource/*:../extensions/doc/*:../extensions/extensionmanager/*:../extensions/file/*:../extensions/globalmapviewer/*:../extensions/http/*:../extensions/httpauth/*:../extensions/imageviewer/*:../extensions/javascriptrule/*:../extensions/javascriptstep/*:../extensions/jdbc/*:../extensions/jms/*:../extensions/js/*:../extensions/mapper/*:../extensions/messagebuilder/*:../extensions/mllpmode/*:../extensions/pdfviewer/*:../extensions/rulebuilder/*:../extensions/scriptfilerule/*:../extensions/scriptfilestep/*:../extensions/serverlog/*:../extensions/smtp/*:../extensions/tcp/*:../extensions/textviewer/*:../extensions/vm/*:../extensions/ws/*:../extensions/xsltstep/*:../extensions/dicom/lib/*:../extensions/dicomviewer/lib/*:../extensions/doc/lib/*:../extensions/file/lib/*:../extensions/httpauth/src/*:../extensions/pdfviewer/lib/*:../extensions/ws/lib/*"
                },
                "cwd": "/Users/israeltorres/Documents/Mirth Connect/3.7.1/server-lib"
            }
        },
        {
            "label": "Build",
            "dependsOn": [
                "Concat Files",
                "Run in Rhino shell"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
init.js
Code:
importPackage(com.mirth.connect.server.userutil)
var logger = { "info": (a) => { java.lang.System.out.println(a) } }
msg.txt
Code:
msg = "hello";
main.js
Code:
logger.info(msg);
Reply With Quote
  #20  
Old 06-24-2019, 07:47 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 967
agermano is on a distinguished road
Default

Real logger support:
Code:
org.apache.log4j.BasicConfigurator.configure();
var logger = org.apache.log4j.LogManager.getRootLogger();
First line adds a ConsoleAppender to the root logger.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:51 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation