01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.support.log;
14:
15: import java.util.HashSet;
16: import java.util.Set;
17:
18: import org.apache.log4j.Level;
19: import org.apache.log4j.Logger;
20:
21: import com.eviware.soapui.SoapUI;
22: import com.eviware.soapui.model.testsuite.LoadTestRunner;
23: import com.eviware.soapui.monitor.support.TestMonitorListenerAdapter;
24: import com.eviware.soapui.settings.UISettings;
25:
26: /**
27: * Disables httpclient and groovy logs during loadtests
28: *
29: * @author ole
30: */
31:
32: public final class LogDisablingTestMonitorListener extends
33: TestMonitorListenerAdapter {
34: private Set<LoadTestRunner> loadTestRunners = new HashSet<LoadTestRunner>();
35:
36: public void loadTestStarted(LoadTestRunner runner) {
37: if (loadTestRunners.isEmpty()) {
38: Logger.getLogger(SoapUI.class).info(
39: "Disabling logs during loadtests");
40: Logger.getLogger("httpclient.wire").setLevel(Level.OFF);
41:
42: if (!SoapUI.getSettings().getBoolean(
43: UISettings.DONT_DISABLE_GROOVY_LOG))
44: Logger.getLogger("groovy.log").setLevel(Level.OFF);
45: }
46:
47: loadTestRunners.add(runner);
48: }
49:
50: public void loadTestFinished(LoadTestRunner runner) {
51: loadTestRunners.remove(runner);
52:
53: if (loadTestRunners.isEmpty()) {
54: Logger.getLogger("httpclient.wire").setLevel(Level.DEBUG);
55: Logger.getLogger("groovy.log").setLevel(Level.DEBUG);
56: Logger.getLogger(SoapUI.class).info(
57: "Enabled logs after loadtests");
58: }
59: }
60: }
|