Skip to content

Instantly share code, notes, and snippets.

@chumpa
Last active April 25, 2018 15:45
Show Gist options
  • Save chumpa/776325d2a9e8c907f91a418483b982e3 to your computer and use it in GitHub Desktop.
Save chumpa/776325d2a9e8c907f91a418483b982e3 to your computer and use it in GitHub Desktop.
cpi message processing log attachment conditional output
// More clear version. Note for CpiMsg import alias
import com.sap.gateway.ip.core.customdev.util.Message as CpiMsg
CpiMsg log2(CpiMsg msg) {
def mlog = messageLogFactory.getMessageLog(msg)
String body = msg.getBody(String.class)
String ll = msg.properties.SAP_MessageProcessingLogConfiguration.logLevel.toString() //NONE, INFO, DEBUG, Trace
if (ll in ['DEBUG', 'Trace'])
mlog.addAttachmentAsString(ll, body, 'application/binary')
mlog.addAttachmentAsString('const', body, 'application/binary')
msg
}
@chumpa
Copy link
Author

chumpa commented Apr 25, 2018

More clear version. Note for CpiMsg import alias

CpiMsg log2(CpiMsg msg) {
    def mlog = messageLogFactory.getMessageLog(msg)
    String body = msg.getBody(String.class)
    String ll = msg.properties.SAP_MessageProcessingLogConfiguration.logLevel.toString()  //NONE, INFO, DEBUG, Trace
    if (ll in ['DEBUG', 'Trace']) 
        mlog.addAttachmentAsString(ll, body, 'application/binary')
    mlog.addAttachmentAsString('const', body, 'application/binary')
    msg
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment