-
Notifications
You must be signed in to change notification settings - Fork 214
/
WithMdcEntry.java
98 lines (89 loc) · 4.31 KB
/
WithMdcEntry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.internal.utils.pekko.logging;
import javax.annotation.Nullable;
import org.slf4j.Logger;
/**
* This interface defines the means to put and remove entries to or from the MDC of a logger.
*
* @param <L> the type of the logger that implements this interface.
* @since 1.4.0
*/
public interface WithMdcEntry<L extends Logger> {
/**
* Puts the specified diagnostic context value as identified by the specified key to this logger's MDC.
* <p>
* Providing {@code null} as value has the same effect as calling {@link #removeMdcEntry(CharSequence)} with the
* specified key.
* </p>
*
* @param key the key which identifies the diagnostic value.
* @param value the diagnostic value which is identified by {@code key}.
* @return this or a new logger instance for method chaining.
* @throws NullPointerException if {@code key} is {@code null}.
* @throws IllegalArgumentException if {@code key} is empty.
*/
L withMdcEntry(CharSequence key, @Nullable CharSequence value);
/**
* Puts the specified diagnostic context values as identified by the specified keys to this logger's MDC.
* <p>
* Providing {@code null} for any value has the same effect as calling {@link #removeMdcEntry(CharSequence)} with
* its associated key.
* </p>
*
* @param k1 the first key which identifies the diagnostic value {@code v1}.
* @param v1 the first diagnostic value which is identified by {@code k1}.
* @param k2 the second key which identifies the diagnostic value {@code v2}.
* @param v2 the second diagnostic value which is identified by {@code k2}.
* @return this or a new logger instance for method chaining.
* @throws NullPointerException if {@code k1} or {@code k2} is {@code null}.
* @throws IllegalArgumentException if {@code k1} or {@code k2} is empty.
*/
L withMdcEntries(CharSequence k1, @Nullable CharSequence v1, CharSequence k2, @Nullable CharSequence v2);
/**
* Puts the specified diagnostic context values as identified by the specified keys to this logger's MDC.
* <p>
* Providing {@code null} for any value has the same effect as calling {@link #removeMdcEntry(CharSequence)} with
* its associated key.
* </p>
*
* @param k1 the first key which identifies the diagnostic value {@code v1}.
* @param v1 the first diagnostic value which is identified by {@code k1}.
* @param k2 the second key which identifies the diagnostic value {@code v2}.
* @param v2 the second diagnostic value which is identified by {@code k2}.
* @param k3 the third key which identifies the diagnostic value {@code v3}.
* @param v3 the third diagnostic value which is identified by {@code k3}.
* @return this or a new logger instance for method chaining.
* @throws NullPointerException if {@code k1}, {@code k2} or {@code k3} is {@code null}.
* @throws IllegalArgumentException if {@code k1}, {@code k2} or {@code k3} is empty.
*/
L withMdcEntries(CharSequence k1, @Nullable CharSequence v1, CharSequence k2, @Nullable CharSequence v2,
CharSequence k3, @Nullable CharSequence v3);
/**
* Puts the given entry (entries) to the MDC of this logger.
*
* @return this or a new logger instance for method chaining.
* @throws NullPointerException if any argument is {@code null}.
*/
L withMdcEntry(MdcEntry mdcEntry, MdcEntry... furtherMdcEntries);
/**
* Removes the diagnostic context value identified by the specified key.
* This method does nothing if there is no previous value associated with the specified key.
*
* @param key the key of the value to be removed.
* @return this or a new logger instance for method chaining.
* @throws NullPointerException if {@code key} is {@code null}.
* @throws IllegalArgumentException if {@code key} is empty.
*/
L removeMdcEntry(CharSequence key);
}