@@ -84,22 +84,36 @@ public void log(String message, Object... args) {
8484 log (loggingEvent );
8585 }
8686
87- protected void log (LoggingEvent logggingEvent ) {
87+ @ Override
88+ public void log (Supplier <String > messageSupplier ) {
89+ if (messageSupplier == null ) {
90+ log ((String ) null );
91+ } else {
92+ log (messageSupplier .get ());
93+ }
94+ }
95+
96+ @ Override
97+ public void log () {
98+ log (loggingEvent );
99+ }
100+
101+ protected void log (LoggingEvent loggingEvent ) {
88102 if (logger instanceof LoggingEventAware ) {
89- ((LoggingEventAware ) logger ).log (logggingEvent );
103+ ((LoggingEventAware ) logger ).log (loggingEvent );
90104 } else {
91- logViaPublicSLF4JLoggerAPI (logggingEvent );
105+ logViaPublicSLF4JLoggerAPI (loggingEvent );
92106 }
93107 }
94108
95- private void logViaPublicSLF4JLoggerAPI (LoggingEvent logggingEvent ) {
96- Object [] argArray = logggingEvent .getArgumentArray ();
109+ private void logViaPublicSLF4JLoggerAPI (LoggingEvent loggingEvent ) {
110+ Object [] argArray = loggingEvent .getArgumentArray ();
97111 int argLen = argArray == null ? 0 : argArray .length ;
98112
99- Throwable t = logggingEvent .getThrowable ();
113+ Throwable t = loggingEvent .getThrowable ();
100114 int tLen = t == null ? 0 : 1 ;
101115
102- String msg = logggingEvent .getMessage ();
116+ String msg = loggingEvent .getMessage ();
103117
104118 Object [] combinedArguments = new Object [argLen + tLen ];
105119
@@ -110,9 +124,9 @@ private void logViaPublicSLF4JLoggerAPI(LoggingEvent logggingEvent) {
110124 combinedArguments [argLen ] = t ;
111125 }
112126
113- msg = mergeMarkersAndKeyValuePairs (logggingEvent , msg );
127+ msg = mergeMarkersAndKeyValuePairs (loggingEvent , msg );
114128
115- switch (logggingEvent .getLevel ()) {
129+ switch (loggingEvent .getLevel ()) {
116130 case TRACE :
117131 logger .trace (msg , combinedArguments );
118132 break ;
@@ -135,27 +149,27 @@ private void logViaPublicSLF4JLoggerAPI(LoggingEvent logggingEvent) {
135149 /**
136150 * Prepend markers and key-value pairs to the message.
137151 *
138- * @param logggingEvent
152+ * @param loggingEvent
139153 * @param msg
140154 * @return
141155 */
142- private String mergeMarkersAndKeyValuePairs (LoggingEvent logggingEvent , String msg ) {
156+ private String mergeMarkersAndKeyValuePairs (LoggingEvent loggingEvent , String msg ) {
143157
144158 StringBuilder sb = null ;
145159
146- if (loggingEvent .getMarkers () != null ) {
160+ if (this . loggingEvent .getMarkers () != null ) {
147161 sb = new StringBuilder ();
148- for (Marker marker : logggingEvent .getMarkers ()) {
162+ for (Marker marker : loggingEvent .getMarkers ()) {
149163 sb .append (marker );
150164 sb .append (' ' );
151165 }
152166 }
153167
154- if (logggingEvent .getKeyValuePairs () != null ) {
168+ if (loggingEvent .getKeyValuePairs () != null ) {
155169 if (sb == null ) {
156170 sb = new StringBuilder ();
157171 }
158- for (KeyValuePair kvp : logggingEvent .getKeyValuePairs ()) {
172+ for (KeyValuePair kvp : loggingEvent .getKeyValuePairs ()) {
159173 sb .append (kvp .key );
160174 sb .append ('=' );
161175 sb .append (kvp .value );
@@ -171,15 +185,6 @@ private String mergeMarkersAndKeyValuePairs(LoggingEvent logggingEvent, String m
171185 }
172186 }
173187
174- @ Override
175- public void log (Supplier <String > messageSupplier ) {
176- if (messageSupplier == null ) {
177- log ((String ) null );
178- } else {
179- log (messageSupplier .get ());
180- }
181- }
182-
183188 @ Override
184189 public LoggingEventBuilder addKeyValue (String key , Object value ) {
185190 loggingEvent .addKeyValue (key , value );
@@ -192,8 +197,17 @@ public LoggingEventBuilder addKeyValue(String key, Supplier<Object> value) {
192197 return this ;
193198 }
194199
195-
200+ @ Override
201+ public LoggingEventBuilder message (String message ) {
202+ loggingEvent .setMessage (message );
203+ return this ;
204+ }
205+
206+ @ Override
207+ public LoggingEventBuilder message (Supplier <String > messageSupplier ) {
208+ loggingEvent .setMessage (messageSupplier == null ? null : messageSupplier .get ());
209+ return this ;
210+ }
196211
197-
198212
199213}
0 commit comments