@@ -53,27 +53,10 @@ public LogEvent apply(ILoggingEvent iLoggingEvent) {
5353 String threadName = iLoggingEvent .getThreadName ();
5454 ZonedDateTime timeStamp = ZonedDateTime .ofInstant (Instant .ofEpochMilli (iLoggingEvent .getTimeStamp ()), ZoneOffset .UTC );
5555 Map <String , String > diagnosticContext = Collections .unmodifiableMap (iLoggingEvent .getMDCPropertyMap ());
56- List <Map .Entry <String , Object >> keyValuePairs = iLoggingEvent .getKeyValuePairs () == null ? Collections .emptyList () : iLoggingEvent .getKeyValuePairs ().stream ()
57- .map (keyValuePair -> new SimpleImmutableEntry <>(keyValuePair .key , keyValuePair .value ))
58- .collect (Collectors .collectingAndThen (Collectors .toList (), Collections ::unmodifiableList ));
59-
60- List <Object > arguments = Optional .ofNullable (iLoggingEvent .getArgumentArray ())
61- .map (Arrays ::asList )
62- .map (Collections ::unmodifiableList )
63- .orElseGet (Collections ::emptyList );
64-
65- Throwable throwable = Optional .ofNullable (iLoggingEvent .getThrowableProxy ())
66- .filter (ThrowableProxy .class ::isInstance )
67- .map (ThrowableProxy .class ::cast )
68- .map (ThrowableProxy ::getThrowable )
69- .orElse (null );
70-
71- List <LogMarker > logMarkers = Collections .emptyList ();
72- if (iLoggingEvent .getMarkerList () != null ) {
73- logMarkers = iLoggingEvent .getMarkerList ().stream ()
74- .map (MarkerMapper .getInstance ())
75- .collect (Collectors .collectingAndThen (Collectors .toList (), Collections ::unmodifiableList ));
76- }
56+ List <Map .Entry <String , Object >> keyValuePairs = mapKeyValuePairs (iLoggingEvent );
57+ List <Object > arguments = mapArguments (iLoggingEvent );
58+ Throwable throwable = mapThrowable (iLoggingEvent );
59+ List <LogMarker > logMarkers = mapMarkers (iLoggingEvent );
7760
7861 return new LogEvent (
7962 message ,
@@ -90,6 +73,41 @@ public LogEvent apply(ILoggingEvent iLoggingEvent) {
9073 );
9174 }
9275
76+ private static List <Map .Entry <String , Object >> mapKeyValuePairs (ILoggingEvent iLoggingEvent ) {
77+ if (iLoggingEvent .getKeyValuePairs () == null ) {
78+ return Collections .emptyList ();
79+ }
80+
81+ return iLoggingEvent .getKeyValuePairs ().stream ()
82+ .map (keyValuePair -> new SimpleImmutableEntry <>(keyValuePair .key , keyValuePair .value ))
83+ .collect (Collectors .collectingAndThen (Collectors .toList (), Collections ::unmodifiableList ));
84+ }
85+
86+ private static Throwable mapThrowable (ILoggingEvent iLoggingEvent ) {
87+ return Optional .ofNullable (iLoggingEvent .getThrowableProxy ())
88+ .filter (ThrowableProxy .class ::isInstance )
89+ .map (ThrowableProxy .class ::cast )
90+ .map (ThrowableProxy ::getThrowable )
91+ .orElse (null );
92+ }
93+
94+ private static List <Object > mapArguments (ILoggingEvent iLoggingEvent ) {
95+ return Optional .ofNullable (iLoggingEvent .getArgumentArray ())
96+ .map (Arrays ::asList )
97+ .map (Collections ::unmodifiableList )
98+ .orElseGet (Collections ::emptyList );
99+ }
100+
101+ private static List <LogMarker > mapMarkers (ILoggingEvent iLoggingEvent ) {
102+ if (iLoggingEvent .getMarkerList () == null ) {
103+ return Collections .emptyList ();
104+ }
105+
106+ return iLoggingEvent .getMarkerList ().stream ()
107+ .map (MarkerMapper .getInstance ())
108+ .collect (Collectors .collectingAndThen (Collectors .toList (), Collections ::unmodifiableList ));
109+ }
110+
93111 public static LogEventMapper getInstance () {
94112 return INSTANCE ;
95113 }
0 commit comments