@@ -128,11 +128,41 @@ struct stumpless_target;
128128 * @param entry The entry that is being submitted to the target. Will not be
129129 * NULL when called during logging.
130130 *
131+ * @param data A pointer to data that may hold anything that the filter function
132+ * needs to use in addition to the target and entry.
133+ *
131134 * @return true if the entry should be sent to the target, false if not.
132135 */
133136typedef bool ( * stumpless_filter_func_t )(
134137 const struct stumpless_target * target ,
135- const struct stumpless_entry * entry );
138+ const struct stumpless_entry * entry ,
139+ void * data );
140+
141+ /**
142+ * A function that maps a given entry to another.
143+ *
144+ * Map functions are useful for adding, removing, or otherwise modifying an
145+ * entry before it is logged to a target. They return a pointer to the mapped
146+ * entry.
147+ *
148+ * Map functions should not modify the entry they operate on. If no modification
149+ * is needed, then it is better to simply not specify a map function.
150+ *
151+ * @since release v3.0.0
152+ *
153+ * @param target The target that the map function was called as part of.
154+ *
155+ * @param entry The entry that this map function will base its output on.
156+ *
157+ * @param data A pointer to data that may hold anything that the map function
158+ * needs to use in addition to the target and entry.
159+ *
160+ * @return A pointer to the mapped entry.
161+ */
162+ typedef struct stumpless_entry * ( * stumpless_map_func_t )(
163+ const struct stumpless_target * target ,
164+ const struct stumpless_entry * entry ,
165+ void * data );
136166
137167/**
138168 * A target that log entries can be sent to.
@@ -188,6 +218,30 @@ struct stumpless_target {
188218 * @since release v2.1.0
189219 */
190220 stumpless_filter_func_t filter ;
221+ /**
222+ * A pointer to data which may be used by the filter function.
223+ *
224+ * @since release v3.0.0
225+ */
226+ void * filter_data ;
227+ /**
228+ * A mapping function which will map the entry the target recieved to one that
229+ * will be logged. This supports things including redacting specific items,
230+ * adding new elements automatically, or mapping element or parameter values to
231+ * other entry fields.
232+ *
233+ * If present, the map function is called after the filter, before the entry is
234+ * logged to the target.
235+ *
236+ * @since release v3.0.0
237+ */
238+ stumpless_map_func_t map ;
239+ /**
240+ * A pointer to data which may be used by the map function.
241+ *
242+ * @since release v3.0.0
243+ */
244+ void * map_data ;
191245#ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
192246/**
193247 * A pointer to a mutex which protects all target fields. The exact type of
0 commit comments