View Javadoc
1   /*
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2022, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  
15  package ch.qos.logback.classic.util;
16  
17  import java.io.IOException;
18  
19  import ch.qos.logback.classic.issue.logback1159.LoggingError;
20  import ch.qos.logback.core.spi.ContextAwareBase;
21  import ch.qos.logback.core.spi.LifeCycle;
22  import ch.qos.logback.core.status.Status;
23  import ch.qos.logback.core.status.StatusListener;
24  import ch.qos.logback.core.status.ErrorStatus;
25  
26  /**
27   * This class should be in a folder relating to the issue being tested. However, we place it here for reaasons related
28   * to JMPS package access rules.
29   */
30  public class LogbackListener1159 extends ContextAwareBase implements StatusListener, LifeCycle {
31      private boolean started;
32  
33      @Override
34      public void start() {
35          this.started = true;
36      }
37  
38      @Override
39      public void stop() {
40          this.started = false;
41      }
42  
43      @Override
44      public boolean isStarted() {
45          return this.started;
46      }
47  
48      @Override
49      public void addStatusEvent(final Status status) {
50          if (status instanceof ErrorStatus && status.getThrowable() instanceof IOException) {
51              System.out.println("*************************LogbackListener.addStatusEvent");
52              throw new LoggingError(status.getMessage(), status.getThrowable());
53          }
54      }
55  
56  }