Skip to content

Commit

Permalink
Logged data in debug (#265)
Browse files Browse the repository at this point in the history
* add log.trace for each logged line

* bump version

* changed to debug

* refactor

* added isDebugEnabled

* switch to debug log
  • Loading branch information
rmazurok authored Mar 5, 2024
1 parent b356d91 commit 17d4517
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@
package oap.logstream.net;

import lombok.extern.slf4j.Slf4j;
import oap.io.content.ContentReader;
import oap.logstream.AbstractLoggerBackend;
import oap.logstream.BackendLoggerNotAvailableException;
import oap.logstream.InvalidProtocolVersionException;
import oap.logstream.LogStreamProtocol;
import oap.logstream.LogStreamProtocol.ProtocolVersion;
import oap.logstream.LoggerException;
import oap.message.MessageListener;
import oap.template.BinaryUtils;
import oap.tsv.Tsv;

import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;

import static oap.logstream.LogStreamProtocol.MESSAGE_TYPE;

Expand Down Expand Up @@ -124,8 +130,20 @@ private void readBinaryV2( ProtocolVersion version, String hostName, DataInputSt
var buffer = new byte[length];
in.readFully( buffer, 0, length );

log.trace( "[{}] logging (properties {} filePreffix {} logType {} headers {} types {}, {})",
hostName, properties, filePreffix, logType, headers, types, length );
if ( log.isTraceEnabled() ) {
List<List<Object>> lines = new ArrayList<>();
switch( version ) {
case TSV_V1 -> ContentReader.read( buffer, Tsv.tsv.ofSeparatedValues() ).toList()
.forEach( line -> lines.add( Collections.singletonList( line ) ) );
case BINARY_V2 -> lines.addAll( BinaryUtils.read( buffer ) );
}

lines.forEach( line ->
log.trace( "[{}] logging (properties {} filePreffix {} logType {} headers {} types {}, length {}, line {})",
hostName, properties, filePreffix, logType, headers, types, length, line
)
);
}

backend.log( version, clientHostname, filePreffix, properties, logType, headers, types, buffer, 0, length );
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</repositories>

<properties>
<oap.project.version>21.15.5</oap.project.version>
<oap.project.version>21.15.6</oap.project.version>

<oap.deps.config.version>21.0.0</oap.deps.config.version>
<oap.deps.oap-teamcity.version>21.0.1</oap.deps.oap-teamcity.version>
Expand Down

0 comments on commit 17d4517

Please sign in to comment.