Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 package ch.qos.logback.core.spi;
A helper class that implements ContextAware methods. A class can implement the ContextAware interface by deriving from this class.

Ceki Gülcü
 public class ContextAwareBase implements ContextAware {
   private int noContextWarning = 0;
   protected Context context;
   final Object declaredOrigin;
   public ContextAwareBase() {
      = this;
   public ContextAwareBase(Object declaredOrigin) {
     this. = declaredOrigin;
   public void setContext(Context context) {
     if (this. == null) {
       this. = context;
     } else if (this. != context) {
       throw new IllegalStateException("Context has been already set");
   public Context getContext() {
     return this.;
   public StatusManager getStatusManager() {
     if ( == null) {
       return null;
     return .getStatusManager();

The declared origin of status messages. By default 'this'. Derived classes may override this method to declare other origin.

the declared origin, by default 'this'
   protected Object getDeclaredOrigin() {
     return ;
   public void addStatus(Status status) {
     if ( == null) {
       if (++ == 0) {
         ..println("LOGBACK: No context given for " + this);
     if (sm != null) {
   public void addInfo(String msg) {
     addStatus(new InfoStatus(msggetDeclaredOrigin()));
   public void addInfo(String msgThrowable ex) {
     addStatus(new InfoStatus(msggetDeclaredOrigin(), ex));
   public void addWarn(String msg) {
     addStatus(new WarnStatus(msggetDeclaredOrigin()));
   public void addWarn(String msgThrowable ex) {
     addStatus(new WarnStatus(msggetDeclaredOrigin(), ex));
   public void addError(String msg) {
  public void addError(String msgThrowable ex) {
    addStatus(new ErrorStatus(msggetDeclaredOrigin(), ex));
New to GrepCode? Check out our FAQ X