Skip to content

Commit

Permalink
Remove basic duplicates for json console mode and fin-tuned output of…
Browse files Browse the repository at this point in the history
… sync write in consoleloghandler
  • Loading branch information
Channyboy committed Feb 21, 2018
1 parent 1c695c0 commit d0eece0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,38 @@ public void synchronousWrite(Object event) {

String messageOutput = (String) formatEvent(evensourcetType, CollectorConstants.MEMORY, event, null, MAXFIELDLENGTH);
synchronized (this) {

//Write out accessLog or ffdc or trace
if (sourceType.equals(CollectorConstants.ACCESS_LOG_SOURCE) ||
sourceType.equals(CollectorConstants.TRACE_SOURCE) ||
sourceType.equals(CollectorConstants.FFDC_SOURCE)) {
sysLogHolder.getOriginalStream().println(messageOutput);
return;
}

/*
* We only allow two types of console messages to go through:
*
* 1. Either this message is greater than or equal to consoleLogLevel (i.e from publishLogRecord)
* OR
* 2. CopySystemStreams is true AND this message came from BaseTraceService.TrOutputStream which exhibit the following characteristics:
* 1. CopySystemStreams is true AND this message came from BaseTraceService.TrOutputStream which exhibit the following characteristics:
* - LogLevel of WsLevel.CONFIG
* - LoggerName of LoggingConstants.SYSTEM_OUT (i.e SystemOut) OR loggerNameLoggingConstants.SYSTEM_ERR (i.e. SystemErr)
* OR
* 2. Either this message is greater than or equal to consoleLogLevel (i.e from publishLogRecord)
*
*/
if (logLevelValue >= consoleLogLevel.intValue()) {
sysLogHolder.getOriginalStream().println(messageOutput);
}
//separated for readability***

if (copySystemStreams &&
logLevelValue == WsLevel.CONFIG.intValue() &&
(loggerName.equalsIgnoreCase(LoggingConstants.SYSTEM_OUT) || loggerName.equalsIgnoreCase(LoggingConstants.SYSTEM_ERR))) {
sysLogHolder.getOriginalStream().println(messageOutput);
return;
}

//Other wise we will be writing out accessLog or ffdc or trace
if (sourceType.equals(CollectorConstants.ACCESS_LOG_SOURCE) ||
sourceType.equals(CollectorConstants.TRACE_SOURCE) ||
sourceType.equals(CollectorConstants.FFDC_SOURCE)) {
if (logLevelValue >= consoleLogLevel.intValue()) {
sysLogHolder.getOriginalStream().println(messageOutput);
return;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void echo(SystemLogHolder holder, LogRecord logRecord) {
// preserve System.out vs. System.err
publishTraceLogRecord(holder, logRecord, NULL_ID, NULL_FORMATTED_MSG, NULL_FORMATTED_MSG);
} else {
if (copySystemStreams) {
if (copySystemStreams && !isConsoleJsonConfigured) {
// Tee to console.log if we are copying System.out and System.err to system streams.
writeFilteredStreamOutput(holder, logRecord);
}
Expand Down

0 comments on commit d0eece0

Please sign in to comment.