View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2024, 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  package ch.qos.logback.core.util;
15  
16  import ch.qos.logback.core.Context;
17  import ch.qos.logback.core.status.Status;
18  import ch.qos.logback.core.status.StatusManager;
19  
20  import java.io.PrintStream;
21  import java.util.List;
22  
23  /**
24   * This class print status messages of a given {@link Context}. However, all its methods are
25   * static. Use {@link StatusPrinter2} instead
26   *
27   * @deprecated replaced by {@link StatusPrinter2}
28   */
29  public class StatusPrinter {
30  
31      private final static StatusPrinter2 SINGLETON = new StatusPrinter2();
32  
33      public static void setPrintStream(PrintStream printStream) {
34          SINGLETON.setPrintStream(printStream);
35      }
36  
37      /**
38       * Print the contents of the context statuses, but only if they contain warnings
39       * or errors.
40       *
41       * @param context a context to print
42       */
43      public static void printInCaseOfErrorsOrWarnings(Context context) {
44          SINGLETON.printInCaseOfErrorsOrWarnings(context, 0);
45      }
46  
47      /**
48       * Print the contents of the context status, but only if they contain warnings
49       * or errors occurring later than the threshold.
50       *
51       * @param context a context to print
52       * @param threshold filter events later than the threshold
53       */
54      public static void printInCaseOfErrorsOrWarnings(Context context, long threshold) {
55          SINGLETON.printInCaseOfErrorsOrWarnings(context, threshold);
56      }
57  
58      /**
59       * Print the contents of the context statuses, but only if they contain errors.
60       *
61       * @param context a context to print
62       */
63      public static void printIfErrorsOccured(Context context) {
64          SINGLETON.printIfErrorsOccured(context);
65      }
66  
67      /**
68       * Print the contents of the context's status data.
69       *
70       * @param context a context to print
71       */
72      public static void print(Context context) {
73          SINGLETON.print(context, 0);
74      }
75  
76      /**
77       * Print context's status data with a timestamp higher than the threshold.
78       * 
79       * @param context a context to print
80       * @param threshold filter events later than the threshold
81       */
82      public static void print(Context context, long threshold) {
83          SINGLETON.print(context, threshold);
84      }
85  
86      public static void print(StatusManager sm) {
87          SINGLETON.print(sm, 0);
88      }
89  
90      public static void print(StatusManager sm, long threshold) {
91          SINGLETON.print(sm, threshold);
92      }
93  
94      public static void print(List<Status> statusList) {
95          SINGLETON.print(statusList);
96      }
97  
98      public static void buildStr(StringBuilder sb, String indentation, Status s) {
99          SINGLETON.buildStr(sb, indentation, s);
100     }
101 }