本文整理汇总了Java中org.apache.jorphan.logging.LoggingManager类的典型用法代码示例。如果您正苦于以下问题:Java LoggingManager类的具体用法?Java LoggingManager怎么用?Java LoggingManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoggingManager类属于org.apache.jorphan.logging包,在下文中一共展示了LoggingManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkJMeterVersion
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
private static void checkJMeterVersion() {
try {
String jmeterVersion = JMeterUtils.getJMeterVersion();
Matcher m = Pattern.compile("(\\d+)\\.(\\d+).*").matcher(jmeterVersion);
if (m.matches()) {
int major = Integer.parseInt(m.group(1));
int minor = Integer.parseInt(m.group(2));
if (major < 3 || (major == 3 && minor < 1)) {
String errorMsg = "This version of the WebSocketSamplers plugin requires JMeter 3.1 or later.";
if (GuiPackage.getInstance() != null) {
SwingUtilities.invokeLater(() -> {
GuiPackage.showErrorMessage(errorMsg, "Incompatible versions");
});
} else {
LoggingManager.getLoggerForClass().error(errorMsg);
}
}
}
}
catch (Exception e) {
// Let this method never throw an exception
}
}
示例2: getLogTab
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
private Component getLogTab() {
loggerPanel = new LoggerPanelWrapping();
loggerPanel.setMinimumSize(new Dimension(0, 50));
loggerPanel.setPreferredSize(new Dimension(0, 150));
try {
if (!isJMeter32orLater()) {
LoggingManager.addLogTargetToRootLogger(new LogTarget[]{loggerPanel});
} else {
Class cls = Class.forName("com.blazemeter.jmeter.debugger.logging.LoggerPanelAppender");
Constructor constructor = cls.getConstructor(String.class, LoggerPanelWrapping.class);
constructor.newInstance("debugger-logging-appender", loggerPanel);
}
} catch (Throwable ex) {
log.error("Cannot hook into logging", ex);
}
return loggerPanel;
}
示例3: doAction
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
@Override
public void doAction(ActionEvent e) throws IllegalUserActionException {
JMeterTreeNode node= GuiPackage.getInstance().getTreeListener().getCurrentNode();
TestElement te = (TestElement)node.getUserObject();
if (ActionNames.WHAT_CLASS.equals(e.getActionCommand())){
String guiClassName = te.getPropertyAsString(TestElement.GUI_CLASS);
System.out.println(te.getClass().getName());
System.out.println(guiClassName);
log.info("TestElement:"+te.getClass().getName()+", guiClassName:"+guiClassName);
} else if (ActionNames.DEBUG_ON.equals(e.getActionCommand())){
LoggingManager.setPriorityFullName("DEBUG",te.getClass().getName());//$NON-NLS-1$
} else if (ActionNames.DEBUG_OFF.equals(e.getActionCommand())){
LoggingManager.setPriorityFullName("INFO",te.getClass().getName());//$NON-NLS-1$
} else if (ActionNames.HEAP_DUMP.equals(e.getActionCommand())){
try {
String s = HeapDumper.dumpHeap();
JOptionPane.showMessageDialog(null, "Created "+s, "HeapDump", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.toString(), "HeapDump", JOptionPane.ERROR_MESSAGE);
}
}
}
示例4: main
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
public static void main(String args[]){
int port = HttpMirrorControl.DEFAULT_PORT;
if (args.length > 0){
port = Integer.parseInt(args[0]);
}
LoggingManager.setPriority("INFO"); // default level
LoggingManager.setLoggingLevels(System.getProperties() ); // allow override by system properties
HttpMirrorServer serv = new HttpMirrorServer(port);
serv.start();
}
示例5: populateBindings
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
/**
* Populate variables to be passed to scripts
* @param bindings Bindings
*/
protected void populateBindings(Bindings bindings) {
final String label = getName();
final String fileName = getFilename();
final String scriptParameters = getParameters();
// Use actual class name for log
final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName());
bindings.put("log", logger);
bindings.put("Label", label);
bindings.put("FileName", fileName);
bindings.put("Parameters", scriptParameters);
String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
bindings.put("args", args);
// Add variables for access to context and variables
JMeterContext jmctx = JMeterContextService.getContext();
bindings.put("ctx", jmctx);
JMeterVariables vars = jmctx.getVariables();
bindings.put("vars", vars);
Properties props = JMeterUtils.getJMeterProperties();
bindings.put("props", props);
// For use in debugging:
bindings.put("OUT", System.out);
// Most subclasses will need these:
Sampler sampler = jmctx.getCurrentSampler();
bindings.put("sampler", sampler);
SampleResult prev = jmctx.getPreviousResult();
bindings.put("prev", prev);
}
示例6: initManager
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
protected void initManager(BSFManager mgr) throws BSFException{
final String label = getName();
final String fileName = getFilename();
final String scriptParameters = getParameters();
// Use actual class name for log
final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName());
mgr.declareBean("log", logger, Logger.class); // $NON-NLS-1$
mgr.declareBean("Label",label, String.class); // $NON-NLS-1$
mgr.declareBean("FileName",fileName, String.class); // $NON-NLS-1$
mgr.declareBean("Parameters", scriptParameters, String.class); // $NON-NLS-1$
String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
mgr.declareBean("args",args,args.getClass());//$NON-NLS-1$
// Add variables for access to context and variables
JMeterContext jmctx = JMeterContextService.getContext();
JMeterVariables vars = jmctx.getVariables();
Properties props = JMeterUtils.getJMeterProperties();
mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$
mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$
mgr.declareBean("props", props, props.getClass()); // $NON-NLS-1$
// For use in debugging:
mgr.declareBean("OUT", System.out, PrintStream.class); // $NON-NLS-1$
// Most subclasses will need these:
Sampler sampler = jmctx.getCurrentSampler();
mgr.declareBean("sampler", sampler, Sampler.class);
SampleResult prev = jmctx.getPreviousResult();
mgr.declareBean("prev", prev, SampleResult.class);
}
示例7: testAdd1
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
public void testAdd1() throws Exception {
Logger log = LoggingManager.getLoggerForClass();
Collection<String> treePath = Arrays.asList(new String[] { "1", "2", "3", "4" });
HashTree tree = new HashTree();
log.debug("treePath = " + treePath);
tree.add(treePath, "value");
log.debug("Now treePath = " + treePath);
log.debug(tree.toString());
assertEquals(1, tree.list(treePath).size());
assertEquals("value", tree.getArray(treePath)[0]);
}
示例8: processParams
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
protected int processParams(ListIterator<?> args)
throws UnsupportedOperationException, IllegalArgumentException {
LoggingManager.setPriority(Priority.INFO);
PerfMonWorker worker;
try {
worker = getWorker();
} catch (IOException ex) {
log.error("Error", ex);
return 0;
}
while (args.hasNext()) {
String nextArg = (String) args.next();
log.debug("Arg: " + nextArg);
if (nextArg.equalsIgnoreCase("--tcp-port")) {
if (!args.hasNext()) {
throw new IllegalArgumentException("Missing TCP Port no");
}
worker.setTCPPort(Integer.parseInt((String) args.next()));
} else if (nextArg.equals("--loglevel")) {
args.remove();
String loglevelStr = (String) args.next();
LoggingManager.setPriority(loglevelStr);
} else if (nextArg.equalsIgnoreCase("--interval")) {
if (!args.hasNext()) {
throw new IllegalArgumentException("Missing interval specification");
}
worker.setInterval(Long.parseLong((String) args.next()));
} else if (nextArg.equalsIgnoreCase("--udp-port")) {
if (!args.hasNext()) {
throw new IllegalArgumentException("Missing UDP Port no");
}
worker.setUDPPort(Integer.parseInt((String) args.next()));
} else if (nextArg.equals("--auto-shutdown")) {
args.remove();
worker.setAutoShutdown();
} else if (nextArg.equals("--sysinfo")) {
args.remove();
worker.logSysInfo();
} else if (nextArg.equals("--agent-version")) {
args.remove();
worker.logVersion();
} else {
throw new UnsupportedOperationException("Unrecognized option: " + nextArg);
}
}
try {
worker.startAcceptingCommands();
while (!worker.isFinished()) {
worker.processCommands();
}
} catch (IOException e) {
log.error("Error", e);
return 0;
}
return worker.getExitCode();
}
示例9: runJMeter
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
protected void runJMeter(String className) throws Exception {
int iterations = Integer.valueOf(getTestConfiguration(className, "iterations", "1"));
int threads = Integer.valueOf(getTestConfiguration(className, "threads", "1"));
log.info("starting test " + StringUtils.substringAfterLast(className, "."));
// loop controller
LoopController loopController = new LoopController();
loopController.setLoops(iterations);
loopController.setFirst(true);
loopController.initialize();
// thread group
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(threads);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// JavaSampler
JavaSampler javaSampler = new JavaSampler();
javaSampler.setClassname(className);
javaSampler.setArguments(arguments);
// summary
Summariser summariser = new Summariser("summary");
ResultCollector logger = new ResultCollector(summariser);
// simple listener to track if at least one test failed
GlobalResult globalResult = new GlobalResult();
// create test plan
TestPlan testPlan = new TestPlan();
// assemble the test plan from previously initialized elements
HashTree testPlanHashTree = new HashTree();
testPlanHashTree.add(testPlan);
HashTree threadGroupHashTree = new HashTree();
threadGroupHashTree = testPlanHashTree.add(testPlan, threadGroup);
HashTree javaSamplerHashTree = new HashTree();
javaSamplerHashTree = threadGroupHashTree.add(javaSampler);
javaSamplerHashTree.add(logger);
javaSamplerHashTree.add(globalResult);
// start JMeter test
StandardJMeterEngine jmeter = new StandardJMeterEngine();
jmeter.configure(testPlanHashTree);
jmeter.run();
// increase log level to display the final summary
LoggingManager.setPriority(Priority.INFO, "jmeter.reporters.Summariser");
logger.testEnded();
LoggingManager.setPriority(Priority.WARN, "jmeter.reporters.Summariser");
// set the JUnit test result
assertTrue(!globalResult.isFailed());
}
示例10: initLogging
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
/**
* Initialise JMeter logging
*/
public static void initLogging() {
LoggingManager.initializeLogging(appProperties);
}
示例11: init
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
/**
* Create the GUI components and layout.
*/
private void init() {
menuBar = new JMeterMenuBar();
setJMenuBar(menuBar);
JPanel all = new JPanel(new BorderLayout());
all.add(createToolBar(), BorderLayout.NORTH);
JSplitPane treeAndMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
treePanel = createTreePanel();
treeAndMain.setLeftComponent(treePanel);
JSplitPane topAndDown = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
topAndDown.setOneTouchExpandable(true);
topAndDown.setDividerLocation(0.8);
topAndDown.setResizeWeight(.8);
topAndDown.setContinuousLayout(true);
topAndDown.setBorder(null); // see bug jdk 4131528
if (!DISPLAY_LOGGER_PANEL) {
topAndDown.setDividerSize(0);
}
mainPanel = createMainPanel();
logPanel = createLoggerPanel();
if (DISPLAY_ERROR_FATAL_COUNTER) {
errorsAndFatalsCounterLogTarget = new ErrorsAndFatalsCounterLogTarget();
LoggingManager.addLogTargetToRootLogger(new LogTarget[]{
logPanel,
errorsAndFatalsCounterLogTarget
});
} else {
LoggingManager.addLogTargetToRootLogger(new LogTarget[]{
logPanel
});
}
topAndDown.setTopComponent(mainPanel);
topAndDown.setBottomComponent(logPanel);
treeAndMain.setRightComponent(topAndDown);
treeAndMain.setResizeWeight(.2);
treeAndMain.setContinuousLayout(true);
all.add(treeAndMain, BorderLayout.CENTER);
getContentPane().add(all);
tree.setSelectionRow(1);
addWindowListener(new WindowHappenings());
setTitle(DEFAULT_TITLE);
setIconImage(JMeterUtils.getImage("icon-apache.png").getImage());// $NON-NLS-1$
setWindowTitle(); // define AWT WM_CLASS string
}
示例12: LoggerPanel
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
/**
* Pane for display JMeter log file
*/
public LoggerPanel() {
init();
format = new PatternFormatter(LoggingManager.DEFAULT_PATTERN + "\n"); // $NON-NLS-1$
}
示例13: setUp
import org.apache.jorphan.logging.LoggingManager; //导入依赖的package包/类
@Override
public void setUp(){
LoggingManager.setPriority("FATAL_ERROR",LoggingManager.removePrefix(Functor.class.getName()));
}