001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2024, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core.util; 015 016import ch.qos.logback.core.Context; 017import ch.qos.logback.core.status.Status; 018import ch.qos.logback.core.status.StatusManager; 019 020import java.io.PrintStream; 021import java.util.List; 022 023/** 024 * This class print status messages of a given {@link Context}. However, all its methods are 025 * static. Use {@link StatusPrinter2} instead 026 * 027 * @deprecated replaced by {@link StatusPrinter2} 028 */ 029public class StatusPrinter { 030 031 private final static StatusPrinter2 SINGLETON = new StatusPrinter2(); 032 033 public static void setPrintStream(PrintStream printStream) { 034 SINGLETON.setPrintStream(printStream); 035 } 036 037 /** 038 * Print the contents of the context statuses, but only if they contain warnings 039 * or errors. 040 * 041 * @param context a context to print 042 */ 043 public static void printInCaseOfErrorsOrWarnings(Context context) { 044 SINGLETON.printInCaseOfErrorsOrWarnings(context, 0); 045 } 046 047 /** 048 * Print the contents of the context status, but only if they contain warnings 049 * or errors occurring later than the threshold. 050 * 051 * @param context a context to print 052 * @param threshold filter events later than the threshold 053 */ 054 public static void printInCaseOfErrorsOrWarnings(Context context, long threshold) { 055 SINGLETON.printInCaseOfErrorsOrWarnings(context, threshold); 056 } 057 058 /** 059 * Print the contents of the context statuses, but only if they contain errors. 060 * 061 * @param context a context to print 062 */ 063 public static void printIfErrorsOccured(Context context) { 064 SINGLETON.printIfErrorsOccured(context); 065 } 066 067 /** 068 * Print the contents of the context's status data. 069 * 070 * @param context a context to print 071 */ 072 public static void print(Context context) { 073 SINGLETON.print(context, 0); 074 } 075 076 /** 077 * Print context's status data with a timestamp higher than the threshold. 078 * 079 * @param context a context to print 080 * @param threshold filter events later than the threshold 081 */ 082 public static void print(Context context, long threshold) { 083 SINGLETON.print(context, threshold); 084 } 085 086 public static void print(StatusManager sm) { 087 SINGLETON.print(sm, 0); 088 } 089 090 public static void print(StatusManager sm, long threshold) { 091 SINGLETON.print(sm, threshold); 092 } 093 094 public static void print(List<Status> statusList) { 095 SINGLETON.print(statusList); 096 } 097 098 public static void buildStr(StringBuilder sb, String indentation, Status s) { 099 SINGLETON.buildStr(sb, indentation, s); 100 } 101}