public List<String> getStatuses() { List<String> list = new ArrayList<String>(); Iterator<Status> it = context.getStatusManager().getCopyOfStatusList().iterator(); while (it.hasNext()) { list.add(it.next().toString()); } return list; }
public StatusManager getStatusManager() { if (context == null) { return null; } return context.getStatusManager(); }
public StatusManager getStatusManager() { if (context == null) { return null; } return context.getStatusManager(); }
public StatusUtil(Context context) { this.sm = context.getStatusManager(); }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
public List<String> getStatuses() { List<String> list = new ArrayList<String>(); Iterator<Status> it = context.getStatusManager().getCopyOfStatusList() .iterator(); while (it.hasNext()) { list.add(it.next().toString()); } return list; }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
static void addStatus(Context context, Status s) { if (context == null) { System.out.println("Null context in " + ConfigurationWatchList.class.getName()); return; } StatusManager sm = context.getStatusManager(); if (sm == null) return; sm.add(s); }
/** * Returns true if the StatusManager associated with the context passed * as parameter has one or more StatusListener instances registered. Returns * false otherwise. * * @param context * @return true if one or more StatusListeners registered, false otherwise * @since 1.0.8 */ static public boolean contextHasStatusListener(Context context) { StatusManager sm = context.getStatusManager(); if(sm == null) return false; List<StatusListener> listeners = sm.getCopyOfStatusListenerList(); if(listeners == null || listeners.size() == 0) return false; else return true; }
/** * Print context's status data with a timestamp higher than the threshold. * @param context */ public static void print(Context context, long threshold) { if (context == null) { throw new IllegalArgumentException("Context argument cannot be null"); } StatusManager sm = context.getStatusManager(); if (sm == null) { ps.println("WARN: Context named \"" + context.getName() + "\" has no status manager"); } else { print(sm, threshold); } }
/** * Print status messages retrospectively */ private void retrospectivePrint() { if(context == null) return; long now = System.currentTimeMillis(); StatusManager sm = context.getStatusManager(); List<Status> statusList = sm.getCopyOfStatusList(); for (Status status : statusList) { long timestamp = status.getDate(); if (now - timestamp < retrospective) { print(status); } } }
/** * Print the contents of the context status, but only if they contain * warnings or errors occurring later then the threshold. * * @param context */ public static void printInCaseOfErrorsOrWarnings(Context context, long threshold) { if (context == null) { throw new IllegalArgumentException("Context argument cannot be null"); } StatusManager sm = context.getStatusManager(); if (sm == null) { ps.println("WARN: Context named \"" + context.getName() + "\" has no status manager"); } else { StatusUtil statusUtil = new StatusUtil(context); if (statusUtil.getHighestLevel(threshold) >= ErrorStatus.WARN) { print(sm, threshold); } } }
/** * Print the contents of the context statuses, but only if they contain * errors. * * @param context */ public static void printIfErrorsOccured(Context context) { if (context == null) { throw new IllegalArgumentException("Context argument cannot be null"); } StatusManager sm = context.getStatusManager(); if (sm == null) { ps.println("WARN: Context named \"" + context.getName() + "\" has no status manager"); } else { StatusUtil statusUtil = new StatusUtil(context); if (statusUtil.getHighestLevel(0) == ErrorStatus.ERROR) { print(sm); } } }
/** * This utility method adds a new OnConsoleStatusListener to the context * passed as parameter. * * @param context * @since 1.0.1 */ static public void addNewInstanceToContext(Context context) { OnConsoleStatusListener onConsoleStatusListener = new OnConsoleStatusListener(); onConsoleStatusListener.setContext(context); onConsoleStatusListener.start(); context.getStatusManager().add(onConsoleStatusListener); }
public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException { inError = false; String className = attributes.getValue(CLASS_ATTRIBUTE); if (OptionHelper.isEmpty(className)) { addError("Missing class name for statusListener. Near [" + name + "] line " + getLineNumber(ec)); inError = true; return; } try { statusListener = (StatusListener) OptionHelper.instantiateByClassName( className, StatusListener.class, context); ec.getContext().getStatusManager().add(statusListener); if (statusListener instanceof ContextAware) { ((ContextAware) statusListener).setContext(context); } addInfo("Added status listener of type [" + className + "]"); ec.pushObject(statusListener); } catch (Exception e) { inError = true; addError( "Could not create an StatusListener of type [" + className + "].", e); throw new ActionException(e); } }
public void start() { if(pattern == null || pattern.length() == 0) { addError("Empty or null pattern."); return; } try { Parser<E> p = new Parser<E>(pattern); if (getContext() != null) { p.setContext(getContext()); } Node t = p.parse(); this.head = p.compile(t, getEffectiveConverterMap()); if (postCompileProcessor != null) { postCompileProcessor.process(head); } ConverterUtil.setContextForConverters(getContext(), head); ConverterUtil.startConverters(this.head); super.start(); } catch (ScanException sce) { StatusManager sm = getContext().getStatusManager(); sm.add(new ErrorStatus("Failed to parse pattern \"" + getPattern() + "\".", this, sce)); } }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
@Test public void testEntryConditionsCheckNoLayout() { appender.setLayout(null); appender.checkEntryConditions(); assertEquals(1, appender.getContext().getStatusManager().getCount()); }
@Test public void testStarted() { PatternLayoutBase<E> plb = getPatternLayoutBase(); Context context = new ContextBase(); plb.setContext(context); String s = plb.doLayout(getEventObject()); assertEquals("", s); StatusManager sm = context.getStatusManager(); StatusPrinter.print(sm); }