1 17 package org.apache.geronimo.system.logging.log4j; 18 19 import org.apache.log4j.Logger; 20 import org.apache.log4j.Priority; 21 22 25 final class MockLogger extends Logger { 26 final static String MOCK_NAME = "MOCK_NAME"; 27 boolean isEnabledForCalled = false; 28 Priority calledWithPriority = null; 29 boolean logCalled = false; 30 Object calledWithObject; 31 Throwable calledWithThrowable; 32 String calledWithString; 33 boolean isDebugEnabledCalled; 34 boolean isInfoEnabledCalled; 35 private boolean debugEnabled = false; 36 private boolean infoEnabled = false; 37 private boolean enabledFor = false; 38 final Object isEnabledForLock = new Object (); 39 40 MockLogger(String str) { 41 super(str); 42 } 43 44 public boolean isEnabledFor(Priority priority) { 45 synchronized (isEnabledForLock) { 46 isEnabledForCalled = true; 47 calledWithPriority = priority; 48 if (isEnabledForCalled && isDebugEnabledCalled && isInfoEnabledCalled) isEnabledForLock.notifyAll(); 49 return enabledFor; 50 } 51 } 52 53 public boolean isDebugEnabled() { 54 synchronized (isEnabledForLock) { 55 isDebugEnabledCalled = true; 56 if (isEnabledForCalled && isDebugEnabledCalled && isInfoEnabledCalled) isEnabledForLock.notifyAll(); 57 return debugEnabled; 58 } 59 } 60 61 public boolean isInfoEnabled() { 62 synchronized (isEnabledForLock) { 63 isInfoEnabledCalled = true; 64 if (isEnabledForCalled && isDebugEnabledCalled && isInfoEnabledCalled) isEnabledForLock.notifyAll(); 65 return infoEnabled; 66 } 67 } 68 69 public void log(String s, Priority priority, Object o, Throwable throwable) { 70 logCalled = true; 71 calledWithString = s; 72 calledWithPriority = priority; 73 calledWithObject = o; 74 calledWithThrowable = throwable; 75 } 76 77 public void setEnabledFor(boolean enabledFor) { 78 this.enabledFor = enabledFor; 79 } 80 81 public void setDebugEnabled(boolean debugEnabled) { 82 this.debugEnabled = debugEnabled; 83 } 84 85 public void setInfoEnabled(boolean infoEnabled) { 86 this.infoEnabled = infoEnabled; 87 } 88 } 89 | Popular Tags |