|
29 | 29 | import org.slf4j.Marker;
|
30 | 30 |
|
31 | 31 | /**
|
32 |
| - * This is main interface in slf4j's fluent API for creating logging events. |
| 32 | + * This is the main interface in slf4j's fluent API for creating |
| 33 | + * {@link org.slf4j.event.LoggingEvent logging events}. |
33 | 34 | *
|
34 | 35 | * @author Ceki Gülcü
|
35 | 36 | * @since 2.0.0
|
36 |
| - * |
37 | 37 | */
|
38 | 38 | public interface LoggingEventBuilder {
|
39 | 39 |
|
| 40 | + /** |
| 41 | + * Set the cause for the logging event being built. |
| 42 | + * @param cause a throwable |
| 43 | + * @return a LoggingEventBuilder, usually <b>this</b>. |
| 44 | + */ |
40 | 45 | LoggingEventBuilder setCause(Throwable cause);
|
41 | 46 |
|
| 47 | + /** |
| 48 | + * A {@link Marker marker} to the event being built. |
| 49 | + * |
| 50 | + * @param marker a Marker instance to add. |
| 51 | + * @return a LoggingEventBuilder, usually <b>this</b>. |
| 52 | + */ |
42 | 53 | LoggingEventBuilder addMarker(Marker marker);
|
43 | 54 |
|
| 55 | + /** |
| 56 | + * Add an argument to the event being built. |
| 57 | + * |
| 58 | + * @param p an Object to add. |
| 59 | + * @return a LoggingEventBuilder, usually <b>this</b>. |
| 60 | + */ |
44 | 61 | LoggingEventBuilder addArgument(Object p);
|
45 | 62 |
|
| 63 | + /** |
| 64 | + * Add an argument supplier to the event being built. |
| 65 | + * |
| 66 | + * @param objectSupplier an Object supplier to add. |
| 67 | + * @return a LoggingEventBuilder, usually <b>this</b>. |
| 68 | + */ |
46 | 69 | LoggingEventBuilder addArgument(Supplier<?> objectSupplier);
|
47 | 70 |
|
| 71 | + |
| 72 | + /** |
| 73 | + * Add a {@link org.slf4j.event.KeyValuePair key value pair} to the event being built. |
| 74 | + * |
| 75 | + * @param key the key of the key value pair. |
| 76 | + * @param value the value of the key value pair. |
| 77 | + * @return a LoggingEventBuilder, usually <b>this</b>. |
| 78 | + */ |
48 | 79 | LoggingEventBuilder addKeyValue(String key, Object value);
|
49 | 80 |
|
50 |
| - LoggingEventBuilder addKeyValue(String key, Supplier<Object> value); |
| 81 | + /** |
| 82 | + * Add a {@link org.slf4j.event.KeyValuePair key value pair} to the event being built. |
| 83 | + * |
| 84 | + * @param key the key of the key value pair. |
| 85 | + * @param valueSupplier a supplier of a value for the key value pair. |
| 86 | + * @return a LoggingEventBuilder, usually <b>this</b>. |
| 87 | + */ |
| 88 | + LoggingEventBuilder addKeyValue(String key, Supplier<Object> valueSupplier); |
| 89 | + |
| 90 | + /** |
| 91 | + * Sets the message of the logging event. |
| 92 | + * |
| 93 | + * @since 2.0.0-beta0 |
| 94 | + */ |
| 95 | + LoggingEventBuilder setMessage(String message); |
51 | 96 |
|
| 97 | + /** |
| 98 | + * Sets the message of the event via a message supplier. |
| 99 | + * |
| 100 | + * @param messageSupplier supplies a String to be used as the message for the event |
| 101 | + * @since 2.0.0-beta0 |
| 102 | + */ |
| 103 | + LoggingEventBuilder setMessage(Supplier<String> messageSupplier); |
| 104 | + |
| 105 | + /** |
| 106 | + * After the logging event is built, performs actual logging. This method must be called |
| 107 | + * for logging to occur. |
| 108 | + * |
| 109 | + * If the call to {@link #log()} is omitted, a {@link org.slf4j.event.LoggingEvent LoggingEvent} |
| 110 | + * will be built but no logging will occur. |
| 111 | + * |
| 112 | + * @since 2.0.0-beta0 |
| 113 | + */ |
| 114 | + void log(); |
| 115 | + |
| 116 | + /** |
| 117 | + * Equivalent to calling {@link #setMessage(String)} followed by {@link #log()}; |
| 118 | + * |
| 119 | + * @param message the message to log |
| 120 | + */ |
52 | 121 | void log(String message);
|
53 | 122 |
|
| 123 | + /** |
| 124 | + * Equivalent to calling {@link #setMessage(String)} followed by {@link #addArgument(Object)}} |
| 125 | + * and then {@link #log()} |
| 126 | + * |
| 127 | + * @param message the message to log |
| 128 | + * @param arg an argument to be used with the message to log |
| 129 | + */ |
54 | 130 | void log(String message, Object arg);
|
55 | 131 |
|
| 132 | + /** |
| 133 | + * Equivalent to calling {@link #setMessage(String)} followed by two calls to |
| 134 | + * {@link #addArgument(Object)} and then {@link #log()} |
| 135 | + * |
| 136 | + * @param message the message to log |
| 137 | + * @param arg0 first argument to be used with the message to log |
| 138 | + * @param arg1 second argument to be used with the message to log |
| 139 | + */ |
56 | 140 | void log(String message, Object arg0, Object arg1);
|
57 | 141 |
|
| 142 | + |
| 143 | + /** |
| 144 | + * Equivalent to calling {@link #setMessage(String)} followed by zero or more calls to |
| 145 | + * {@link #addArgument(Object)} (depending on the size of args array) and then {@link #log()} |
| 146 | + * |
| 147 | + * @param message the message to log |
| 148 | + * @param args a list (actually an array) of arguments to be used with the message to log |
| 149 | + */ |
58 | 150 | void log(String message, Object... args);
|
59 | 151 |
|
| 152 | + /** |
| 153 | + * Equivalent to calling {@link #setMessage(Supplier)} followed by {@link #log()} |
| 154 | + * |
| 155 | + * @param messageSupplier a Supplier returning a message of type String |
| 156 | + */ |
60 | 157 | void log(Supplier<String> messageSupplier);
|
61 | 158 |
|
62 | 159 | }
|
0 commit comments