slavka
1 supporter
Thrift logger

Thrift logger

Dec 01, 2022

https://github.com/incu6us/thrift-logger

Like to use Thrift as a message type format to your project? Probably, logger for it will be useful.

Dependency:

<dependency>

<groupId>com.github.incu6us.thrift</groupId>

<artifactId>thrift-logger</artifactId>

<version>0.0.1</version>

</dependency>

Usage:

...

final TProcessor processor = new UglyService.Processor<>(new UglyServiceImpl());

final TServerTransport transport = new TServerSocket(port);

server = new TSimpleServer(new TServer.Args(transport).processor(new LogProcessor(processor, new ServerTestLogger())));

new Thread(() -> server.serve()).start();

}

@Slf4j

public class ServerTestLogger<T> implements Logger<T> {

@Override

public void serverResponse(final T field) {

log.info("Server Field: {}", field);

}

@Override

public void clientRequest(final T field) {

log.info("Client Field: {}", field);

}

}

Output:

30 [Thread-0] INFO com.github.incu6us.thrift.logger.LoggerProcessorTest$ServerTestLogger - Client Field: {doSomething: 1: 2: some name}

37 [Thread-0] INFO com.github.incu6us.thrift.logger.LoggerProcessorTest$ServerTestLogger - Server Field: {doSomething: {doSomething_result: {success: {Result: {isSuccess: true}{data: Success}{nested: {NestedResult: {netedData: Nested Data}}}}}}}

38 [main] INFO com.github.incu6us.thrift.logger.LoggerProcessorTest - Result: Result(isSuccess:true, data:Success, nested:NestedResult(netedData:Nested Data))

Enjoy this post?

Buy slavka a coffee

More from slavka