36
36
* A simple logger advisor that logs the request and response messages.
37
37
*
38
38
* @author Christian Tzolov
39
+ * @author Jonghoon Park
39
40
*/
40
41
public class SimpleLoggerAdvisor implements CallAroundAdvisor , StreamAroundAdvisor {
41
42
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 ;
43
44
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 ;
46
46
47
47
private static final Logger logger = LoggerFactory .getLogger (SimpleLoggerAdvisor .class );
48
48
49
49
private final Function <AdvisedRequest , String > requestToString ;
50
50
51
51
private final Function <ChatResponse , String > responseToString ;
52
52
53
- private int order ;
53
+ private final int order ;
54
54
55
55
public SimpleLoggerAdvisor () {
56
56
this (DEFAULT_REQUEST_TO_STRING , DEFAULT_RESPONSE_TO_STRING , 0 );
@@ -60,6 +60,11 @@ public SimpleLoggerAdvisor(int order) {
60
60
this (DEFAULT_REQUEST_TO_STRING , DEFAULT_RESPONSE_TO_STRING , order );
61
61
}
62
62
63
+ public SimpleLoggerAdvisor (Function <AdvisedRequest , String > requestToString ,
64
+ Function <ChatResponse , String > responseToString ) {
65
+ this (requestToString , responseToString , 0 );
66
+ }
67
+
63
68
public SimpleLoggerAdvisor (Function <AdvisedRequest , String > requestToString ,
64
69
Function <ChatResponse , String > responseToString , int order ) {
65
70
this .requestToString = requestToString ;
0 commit comments