3636 * A simple logger advisor that logs the request and response messages.
3737 *
3838 * @author Christian Tzolov
39+ * @author Jonghoon Park
3940 */
4041public class SimpleLoggerAdvisor implements CallAroundAdvisor , StreamAroundAdvisor {
4142
42- public static final Function <AdvisedRequest , String > DEFAULT_REQUEST_TO_STRING = request -> request . toString () ;
43+ public static final Function <AdvisedRequest , String > DEFAULT_REQUEST_TO_STRING = Record :: toString ;
4344
44- public static final Function <ChatResponse , String > DEFAULT_RESPONSE_TO_STRING = response -> ModelOptionsUtils
45- .toJsonStringPrettyPrinter (response );
45+ public static final Function <ChatResponse , String > DEFAULT_RESPONSE_TO_STRING = ModelOptionsUtils ::toJsonStringPrettyPrinter ;
4646
4747 private static final Logger logger = LoggerFactory .getLogger (SimpleLoggerAdvisor .class );
4848
4949 private final Function <AdvisedRequest , String > requestToString ;
5050
5151 private final Function <ChatResponse , String > responseToString ;
5252
53- private int order ;
53+ private final int order ;
5454
5555 public SimpleLoggerAdvisor () {
5656 this (DEFAULT_REQUEST_TO_STRING , DEFAULT_RESPONSE_TO_STRING , 0 );
@@ -60,6 +60,11 @@ public SimpleLoggerAdvisor(int order) {
6060 this (DEFAULT_REQUEST_TO_STRING , DEFAULT_RESPONSE_TO_STRING , order );
6161 }
6262
63+ public SimpleLoggerAdvisor (Function <AdvisedRequest , String > requestToString ,
64+ Function <ChatResponse , String > responseToString ) {
65+ this (requestToString , responseToString , 0 );
66+ }
67+
6368 public SimpleLoggerAdvisor (Function <AdvisedRequest , String > requestToString ,
6469 Function <ChatResponse , String > responseToString , int order ) {
6570 this .requestToString = requestToString ;
0 commit comments