Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Andres Ramirez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,18 @@ public void logger(
}

/* Note:
* This was added because when the payload before the JSON Logger is of type ByteArraySeekableStream
* This was added because when the payload before the JSON Logger is of type ByteArraySeekableStream or ByteArrayInputStream
* (e.g. standard DW output object) and we pass #[payload] as the Message expression, then the stream
* gets consumed but not reset which translates to an "empty stream" for the next processor.
*/
if (event.getMessage().getPayload().getClass().getSimpleName().equals("ByteArraySeekableStream")) {
String payloadClass = event.getMessage().getPayload().getClass().getSimpleName();

if (payloadClass.equals("ByteArraySeekableStream")) {
log.debug("Payload is a ByteArraySeekableStream. Preemptively resetting the stream...");
expressionManager.parse("#[payload.seek(0);]", event);
} else if (payloadClass.equals("ByteArrayInputStream")) {
log.debug("Payload is a ByteArrayInputStream. Preemptively resetting the stream...");
expressionManager.parse("#[payload.reset();]", event);
}
}

Expand Down Expand Up @@ -199,4 +204,4 @@ public void setMuleContext(MuleContext context) {
muleContext = context;
}

}
}
164 changes: 104 additions & 60 deletions json-logger-module/src/main/resources/schema/loggerConfig.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,108 @@
{
"$schema":"http://json-schema.org/draft-04/schema#",
"description":"Definition for fields globally defined in the logger config",
"type":"object",
"properties":{
"prettyPrint":{
"type":"boolean",
"devkit": {
"description": "Currently this field is mandatory so DON'T REMOVE",
"placement":"JSON Output",
"default": "true",
"isConfig": true
}
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Definition for fields globally defined in the logger config",
"type": "object",
"properties": {
"globalSettings": {
"type": "object",
"properties": {
"orgName": {
"type": "string",
"sdk": {
"default": "${json-logger.orgName}",
"summary": "Name of the org. Recommendation: This value should be based on pom.xml"
}
},
"applicationName": {
"type": "string",
"sdk": {
"default": "${json-logger.application.name}",
"summary": "Name of the Mule application. Recommendation: This value should be based on pom.xml"
}
},
"applicationVersion": {
"type": "string",
"sdk": {
"default": "${json-logger.application.version}",
"summary": "Version of the Mule application. Recommendation: This value should be based on pom.xml"
}
},
"environment": {
"type": "string",
"sdk": {
"default": "${json-logger.cloudhub.environment}",
"summary": "Name of the Mule Environment where the application is running. Recommendation: This value should be based on external property"
}
}
},
"timestamp":{
"type":"string",
"devkit": {
"placement":"Default expressions",
"default": "#[new org.joda.time.DateTime().withZone(org.joda.time.DateTimeZone.forID(\"${json.logger.timezone}\")).toString(\"${json.logger.dateformat}\")]",
"isConfig": true
}
},
"rootCorrelationId":{
"type":"string",
"devkit": {
"placement":"Default expressions",
"default": "#[(message.inboundProperties.'x-root-correlation-id' != null)?message.inboundProperties.'x-root-correlation-id':message.id]",
"isConfig": true
}
},
"correlationId":{
"type":"string",
"devkit": {
"placement":"Default expressions",
"default": "#[message.id]",
"isConfig": true
}
},
"applicationName":{
"type":"string",
"devkit": {
"placement":"Global",
"default": "${json.logger.application.name}",
"isConfig": true
}
},
"applicationVersion":{
"type":"string",
"devkit": {
"placement":"Global",
"default": "${json.logger.application.version}",
"isConfig": true
}
"sdk": {
"parameterGroup": "Global Settings",
"expressionSupport": "NOT_SUPPORTED",
"placement": {
"order": 1
}
}
},
"jsonOutput": {
"type": "object",
"properties": {
"prettyPrint": {
"type": "boolean",
"javaType": "boolean",
"sdk": {
"summary": "Indicate if log entries should be formatted or single line",
"default": true,
"expressionSupport": "SUPPORTED"
},
"note": "This field is mandatory. DON'T REMOVE"
},
"logLocationInfo": {
"type": "boolean",
"javaType": "boolean",
"sdk": {
"summary": "Indicate if location information should be logged",
"default": true,
"expressionSupport": "SUPPORTED"
},
"note": "This field is mandatory. DON'T REMOVE"
},
"parseContentFieldsInJsonOutput": {
"type": "boolean",
"javaType": "boolean",
"sdk": {
"summary": "Indicate if Content fields should be parsed as part of the JSON logger output",
"default": true,
"expressionSupport": "SUPPORTED"
},
"note": "This field is mandatory. DON'T REMOVE"
},
"disabledFields": {
"type": "string",
"sdk": {
"default": "${json-logger.disabled-fields}",
"summary": "Indicate which fields (from JSON output) should be disabled from logging separated by comma. They should match the exact name given in loggerProcessor.json schema",
"example": "message,content",
"required": false,
"expressionSupport": "NOT_SUPPORTED"
},
"note": "This field is mandatory. DON'T REMOVE"
},
"contentFieldsDataMasking": {
"type": "string",
"sdk": {
"default": "${json-logger.data-to-mask}",
"summary": "Indicate which fields (inside a content type with JSON output only) should be masked before from logging separated by comma. They can be JSON keys or JSON paths. If empty, no masking will be applied. Recommendation: This value should be based on external property",
"example": "client_secret,password,$.myArray[1].someField,$..path.to.a.field",
"required": false,
"expressionSupport": "NOT_SUPPORTED"
},
"note": "This field is mandatory. DON'T REMOVE"
}
},
"environment":{
"type":"string",
"devkit": {
"placement":"Global",
"default": "${mule.env}",
"isConfig": true
}
"sdk": {
"parameterGroup": "JSON Output",
"expressionSupport": "NOT_SUPPORTED"
}
}
}
}
}
}