1- /// *
2- // * Copyright 2025 Google LLC
3- // *
4- // * Licensed under the Apache License, Version 2.0 (the "License");
5- // * you may not use this file except in compliance with the License.
6- // * You may obtain a copy of the License at
7- // *
8- // * https://www.apache.org/licenses/LICENSE-2.0
9- // *
10- // * Unless required by applicable law or agreed to in writing, software
11- // * distributed under the License is distributed on an "AS IS" BASIS,
12- // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- // * See the License for the specific language governing permissions and
14- // * limitations under the License.
15- // */
16- //
17- // package com.google.showcase.v1beta1.it.logging;
18- //
19- // import ch.qos.logback.classic.spi.ILoggingEvent;
20- // import ch.qos.logback.core.AppenderBase;
21- // import java.util.ArrayList;
22- // import java.util.List;
23- //
24- /// ** Logback appender used to set up tests. */
25- // public class TestAppender extends AppenderBase<ILoggingEvent> {
26- // public List<ILoggingEvent> events = new ArrayList<>();
27- //
28- // @Override
29- // protected void append(ILoggingEvent eventObject) {
30- // // triggering Logback to capture the current MDC context and store it with the log event
31- // // the default ListAppender does not capture MDC contents
32- // eventObject.getMDCPropertyMap();
33- //
34- // events.add(eventObject);
35- // }
36- //
37- // public void clearEvents() {
38- // events.clear();
39- // }
40- // }
1+ /*
2+ * Copyright 2025 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package com .google .showcase .v1beta1 .it .logging ;
18+
19+ import ch .qos .logback .classic .spi .ILoggingEvent ;
20+ import ch .qos .logback .core .AppenderBase ;
21+ import java .util .ArrayList ;
22+ import java .util .List ;
23+
24+ /** Logback appender used to set up tests. */
25+ public class TestAppender extends AppenderBase <ILoggingEvent > {
26+ public List <ILoggingEvent > events = new ArrayList <>();
27+
28+ @ Override
29+ protected void append (ILoggingEvent eventObject ) {
30+ // triggering Logback to capture the current MDC context and store it with the log event
31+ // the default ListAppender does not capture MDC contents
32+ eventObject .getMDCPropertyMap ();
33+
34+ events .add (eventObject );
35+ }
36+
37+ public void clearEvents () {
38+ events .clear ();
39+ }
40+ }
0 commit comments