View | Details | Raw Unified | Return to bug 41788
Collapse All | Expand All

(-)src/core/org/apache/jmeter/resources/messages_fr.properties (+1 lines)
Lines 529-534 Link Here
529
menu_generative_controller=Echantillons
529
menu_generative_controller=Echantillons
530
menu_listener=R\u00E9cepteurs
530
menu_listener=R\u00E9cepteurs
531
menu_logic_controller=Contr\u00F4leurs Logiques
531
menu_logic_controller=Contr\u00F4leurs Logiques
532
menu_logger_panel=Activer/D\u00E9sactiver la console 
532
menu_merge=Fusionner...
533
menu_merge=Fusionner...
533
menu_modifiers=Modificateurs
534
menu_modifiers=Modificateurs
534
menu_non_test_elements=El\u00E9ments hors test
535
menu_non_test_elements=El\u00E9ments hors test
(-)src/core/org/apache/jmeter/resources/messages.properties (+1 lines)
Lines 535-540 Link Here
535
menu_generative_controller=Sampler
535
menu_generative_controller=Sampler
536
menu_listener=Listener
536
menu_listener=Listener
537
menu_logic_controller=Logic Controller
537
menu_logic_controller=Logic Controller
538
menu_logger_panel=Enable/Disable Log Viewer 
538
menu_merge=Merge
539
menu_merge=Merge
539
menu_modifiers=Modifiers
540
menu_modifiers=Modifiers
540
menu_non_test_elements=Non-Test Elements
541
menu_non_test_elements=Non-Test Elements
(-)src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java (+3 lines)
Lines 282-292 Link Here
282
        optionsMenu.add(lafMenu);
282
        optionsMenu.add(lafMenu);
283
283
284
        JCheckBoxMenuItem menuToolBar = makeCheckBoxMenuItemRes("menu_toolbar", ActionNames.TOOLBAR); //$NON-NLS-1$
284
        JCheckBoxMenuItem menuToolBar = makeCheckBoxMenuItemRes("menu_toolbar", ActionNames.TOOLBAR); //$NON-NLS-1$
285
        JCheckBoxMenuItem menuLoggerPanel = makeCheckBoxMenuItemRes("menu_logger_panel", ActionNames.LOGGER_PANEL); //$NON-NLS-1$
285
        GuiPackage guiInstance = GuiPackage.getInstance();
286
        GuiPackage guiInstance = GuiPackage.getInstance();
286
        if (guiInstance != null) { //avoid error in ant task tests (good way?)
287
        if (guiInstance != null) { //avoid error in ant task tests (good way?)
287
            guiInstance.setMenuItemToolbar(menuToolBar);
288
            guiInstance.setMenuItemToolbar(menuToolBar);
289
            guiInstance.setMenuItemLoggerPanel(menuLoggerPanel);
288
        }
290
        }
289
        optionsMenu.add(menuToolBar);
291
        optionsMenu.add(menuToolBar);
292
        optionsMenu.add(menuLoggerPanel);
290
        
293
        
291
        if (SSLManager.isSSLSupported()) {
294
        if (SSLManager.isSSLSupported()) {
292
            sslManager = makeMenuItemRes("sslmanager", 'S', ActionNames.SSL_MANAGER, KeyStrokes.SSL_MANAGER); //$NON-NLS-1$
295
            sslManager = makeMenuItemRes("sslmanager", 'S', ActionNames.SSL_MANAGER, KeyStrokes.SSL_MANAGER); //$NON-NLS-1$
(-)src/core/org/apache/jmeter/gui/MainFrame.java (-1 / +36 lines)
Lines 104-109 Link Here
104
    private static final boolean DISPLAY_TOOLBAR =
104
    private static final boolean DISPLAY_TOOLBAR =
105
            JMeterUtils.getPropDefault("jmeter.toolbar.display", true); // $NON-NLS-1$
105
            JMeterUtils.getPropDefault("jmeter.toolbar.display", true); // $NON-NLS-1$
106
106
107
    // Allow display/hide LoggerPanel
108
    private static final boolean DISPLAY_LOGGER_PANEL =
109
            JMeterUtils.getPropDefault("jmeter.loggerPanel.display", false); // $NON-NLS-1$
110
107
    private static final Logger log = LoggingManager.getLoggerForClass();
111
    private static final Logger log = LoggingManager.getLoggerForClass();
108
112
109
    /** The menu bar. */
113
    /** The menu bar. */
Lines 115-120 Link Here
115
    /** The panel where the test tree is shown. */
119
    /** The panel where the test tree is shown. */
116
    private JScrollPane treePanel;
120
    private JScrollPane treePanel;
117
121
122
    /** The LOG panel. */
123
    private LoggerPanel logPanel;
124
118
    /** The test tree. */
125
    /** The test tree. */
119
    private JTree tree;
126
    private JTree tree;
120
127
Lines 407-414 Link Here
407
        treePanel = createTreePanel();
414
        treePanel = createTreePanel();
408
        treeAndMain.setLeftComponent(treePanel);
415
        treeAndMain.setLeftComponent(treePanel);
409
416
417
        JSplitPane topAndDown = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
418
        topAndDown.setOneTouchExpandable(true);
419
        topAndDown.setDividerLocation(0.8);
420
        topAndDown.setResizeWeight(.8);
421
        topAndDown.setContinuousLayout(true);
422
        
410
        mainPanel = createMainPanel();
423
        mainPanel = createMainPanel();
411
        treeAndMain.setRightComponent(mainPanel);
424
        topAndDown.setTopComponent(mainPanel);
425
        
426
        logPanel = createLogPanel();
427
        logPanel.setVisible(DISPLAY_LOGGER_PANEL);
428
        
429
        topAndDown.setBottomComponent(logPanel);
430
        treeAndMain.setRightComponent(topAndDown);
412
431
413
        treeAndMain.setResizeWeight(.2);
432
        treeAndMain.setResizeWeight(.2);
414
        treeAndMain.setContinuousLayout(true);
433
        treeAndMain.setContinuousLayout(true);
Lines 423-428 Link Here
423
        setIconImage(JMeterUtils.getImage("jmeter.jpg").getImage());// $NON-NLS-1$
442
        setIconImage(JMeterUtils.getImage("jmeter.jpg").getImage());// $NON-NLS-1$
424
    }
443
    }
425
444
445
426
    /**
446
    /**
427
     * Support for Test Plan Dnd
447
     * Support for Test Plan Dnd
428
     * see BUG 52281 (when JDK6 will be minimum JDK target)
448
     * see BUG 52281 (when JDK6 will be minimum JDK target)
Lines 488-493 Link Here
488
    private JScrollPane createMainPanel() {
508
    private JScrollPane createMainPanel() {
489
        return new JScrollPane();
509
        return new JScrollPane();
490
    }
510
    }
511
    
512
    /**
513
     * @return JScrollPane
514
     */
515
    private LoggerPanel createLogPanel() {
516
        LoggerPanel loggerPanel = new LoggerPanel();
517
        loggerPanel.setMinimumSize(new Dimension(0, 100));
518
        loggerPanel.setPreferredSize(new Dimension(0, 150));
519
        LoggingManager.addLogTargetToRootLogger(loggerPanel);
520
        GuiPackage guiInstance = GuiPackage.getInstance();
521
        guiInstance.setLoggerPanel(loggerPanel);
522
        guiInstance.getMenuItemLoggerPanel().getModel().setSelected(DISPLAY_LOGGER_PANEL);
523
524
        return loggerPanel;
525
    }
491
526
492
    /**
527
    /**
493
     * Create and initialize the GUI representation of the test tree.
528
     * Create and initialize the GUI representation of the test tree.
(-)src/core/org/apache/jmeter/gui/LoggerPanel.java (+98 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.gui;
20
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
23
24
import javax.swing.Box;
25
import javax.swing.JPanel;
26
import javax.swing.JScrollPane;
27
import javax.swing.JTextArea;
28
import javax.swing.SwingUtilities;
29
import javax.swing.border.Border;
30
import javax.swing.border.EmptyBorder;
31
32
import org.apache.jorphan.logging.LoggingManager;
33
import org.apache.log.LogEvent;
34
import org.apache.log.LogTarget;
35
import org.apache.log.format.PatternFormatter;
36
37
/**
38
 * 
39
 */
40
public class LoggerPanel extends JPanel implements LogTarget {
41
42
    /**
43
     * 
44
     */
45
    private static final long serialVersionUID = 6911128494402594429L;
46
    private JTextArea textArea;
47
    private PatternFormatter format;
48
49
    /**
50
     * 
51
     */
52
    public LoggerPanel() {
53
        init();
54
        format = new PatternFormatter(LoggingManager.DEFAULT_PATTERN + "\n");
55
    }
56
57
    private void init() {
58
        this.setLayout(new BorderLayout());
59
60
        // MAIN PANEL
61
        Border margin = new EmptyBorder(5, 5, 5, 5);
62
63
        this.setBorder(margin);
64
        
65
        // TEXTAREA
66
        textArea = new JTextArea();
67
        textArea.setEditable(false);
68
        textArea.setLineWrap(false);
69
        JScrollPane areaScrollPane = new JScrollPane(textArea);
70
71
        areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
72
        areaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
73
74
        Box mainPanel = Box.createVerticalBox();
75
        
76
        areaScrollPane.setPreferredSize(new Dimension(mainPanel.getWidth(),mainPanel.getHeight()));
77
        mainPanel.add(areaScrollPane);
78
        this.add(mainPanel, BorderLayout.CENTER); 
79
    }
80
81
    /* (non-Javadoc)
82
     * @see org.apache.log.LogTarget#processEvent(org.apache.log.LogEvent)
83
     */
84
    public void processEvent(final LogEvent logEvent) {
85
        if(!GuiPackage.getInstance().getMenuItemLoggerPanel().getModel().isSelected()) {
86
            return;
87
        }
88
        
89
        SwingUtilities.invokeLater(new Runnable() {
90
            public void run() {
91
                synchronized (textArea) {
92
                    textArea.append(format.format(logEvent));
93
                    textArea.setCaretPosition(textArea.getText().length());
94
                }
95
            }
96
        });
97
    }
98
}
(-)src/core/org/apache/jmeter/gui/GuiPackage.java (+35 lines)
Lines 630-635 Link Here
630
630
631
    private final List<Stoppable> stoppables = Collections.synchronizedList(new ArrayList<Stoppable>());
631
    private final List<Stoppable> stoppables = Collections.synchronizedList(new ArrayList<Stoppable>());
632
632
633
    private JCheckBoxMenuItem menuItemLoggerPanel;
634
635
    private LoggerPanel loggerPanel;
636
633
    /**
637
    /**
634
     * Sets the filepath of the current test plan. It's shown in the main frame
638
     * Sets the filepath of the current test plan. It's shown in the main frame
635
     * title and used on saving.
639
     * title and used on saving.
Lines 729-732 Link Here
729
        list.addAll(stoppables);
733
        list.addAll(stoppables);
730
        return list;
734
        return list;
731
    }
735
    }
736
737
    /**
738
     * Set the menu item LoggerPanel.
739
     * @param menuItemLoggerPanel
740
     */
741
    public void setMenuItemLoggerPanel(JCheckBoxMenuItem menuItemLoggerPanel) {
742
        this.menuItemLoggerPanel = menuItemLoggerPanel;
743
    }
744
    
745
    /**
746
     * Get the menu item LoggerPanel.
747
     *
748
     * @return the menu item LoggerPanel
749
     */
750
    public JCheckBoxMenuItem getMenuItemLoggerPanel() {
751
        return menuItemLoggerPanel;
752
    }
753
754
    /**
755
     * @param loggerPanel LoggerPanel
756
     */
757
    public void setLoggerPanel(LoggerPanel loggerPanel) {
758
        this.loggerPanel = loggerPanel;
759
    }
760
761
    /**
762
     * @return the loggerPanel
763
     */
764
    public LoggerPanel getLoggerPanel() {
765
        return loggerPanel;
766
    }
732
}
767
}
(-)src/core/org/apache/jmeter/gui/action/ActionNames.java (+1 lines)
Lines 60-65 Link Here
60
    public static final String INSERT_AFTER     = "drag_n_drop.insert_after";//$NON-NLS-1$
60
    public static final String INSERT_AFTER     = "drag_n_drop.insert_after";//$NON-NLS-1$
61
    public static final String INSERT_BEFORE    = "drag_n_drop.insert_before";//$NON-NLS-1$
61
    public static final String INSERT_BEFORE    = "drag_n_drop.insert_before";//$NON-NLS-1$
62
    public static final String LAF_PREFIX       = "laf:"; // Look and Feel prefix
62
    public static final String LAF_PREFIX       = "laf:"; // Look and Feel prefix
63
    public static final String LOGGER_PANEL     = "loggerPanel"; // $NON-NLS-1$
63
    public static final String MERGE            = "merge"; // $NON-NLS-1$
64
    public static final String MERGE            = "merge"; // $NON-NLS-1$
64
    public static final String OPEN             = "open"; // $NON-NLS-1$
65
    public static final String OPEN             = "open"; // $NON-NLS-1$
65
    public static final String OPEN_RECENT      = "open_recent"; // $NON-NLS-1$
66
    public static final String OPEN_RECENT      = "open_recent"; // $NON-NLS-1$
(-)src/core/org/apache/jmeter/gui/action/LoggerView.java (+70 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.gui.action;
20
21
import java.awt.event.ActionEvent;
22
import java.util.HashSet;
23
import java.util.Set;
24
25
import org.apache.jmeter.gui.GuiPackage;
26
27
/**
28
 * Hide / unhide LoggerPanel.
29
 *
30
 */
31
public class LoggerView implements Command {
32
33
    private static final Set<String> commands = new HashSet<String>();
34
35
    static {
36
        commands.add(ActionNames.LOGGER_PANEL);
37
    }
38
39
    /**
40
     * Constructor for object.
41
     */
42
    public LoggerView() {
43
    }
44
45
    /**
46
     * Gets the ActionNames attribute of the action
47
     *
48
     * @return the ActionNames value
49
     */
50
    public Set<String> getActionNames() {
51
        return commands;
52
    }
53
54
    /**
55
     * This method performs the actual command processing.
56
     *
57
     * @param e
58
     *            the generic UI action event
59
     */
60
    public void doAction(ActionEvent e) {
61
        if (ActionNames.LOGGER_PANEL.equals(e.getActionCommand())) {
62
            GuiPackage guiInstance = GuiPackage.getInstance();
63
            if (guiInstance.getMenuItemLoggerPanel().getModel().isSelected()) {
64
                guiInstance.getLoggerPanel().setVisible(true);
65
            } else {
66
                guiInstance.getLoggerPanel().setVisible(false);
67
            }
68
        }
69
    }
70
}
(-)src/jorphan/org/apache/jorphan/logging/LoggingManager.java (-2 / +12 lines)
Lines 52-58 Link Here
52
     * Predefined format patterns, selected by the property log_format_type (see
52
     * Predefined format patterns, selected by the property log_format_type (see
53
     * jmeter.properties) The new-line is added later
53
     * jmeter.properties) The new-line is added later
54
     */
54
     */
55
    private static final String DEFAULT_PATTERN = "%{time:yyyy/MM/dd HH:mm:ss} %5.5{priority} - "  //$NON_NLS-1$
55
    public static final String DEFAULT_PATTERN = "%{time:yyyy/MM/dd HH:mm:ss} %5.5{priority} - "  //$NON_NLS-1$
56
            + "%{category}: %{message} %{throwable}"; //$NON_NLS-1$
56
            + "%{category}: %{message} %{throwable}"; //$NON_NLS-1$
57
57
58
    private static final String PATTERN_THREAD_PREFIX = "%{time:yyyy/MM/dd HH:mm:ss} %5.5{priority} "  //$NON_NLS-1$
58
    private static final String PATTERN_THREAD_PREFIX = "%{time:yyyy/MM/dd HH:mm:ss} %5.5{priority} "  //$NON_NLS-1$
Lines 329-335 Link Here
329
     * @param targetFile
329
     * @param targetFile
330
     *            (Writer)
330
     *            (Writer)
331
     */
331
     */
332
    public static synchronized void setTarget(Writer targetFile) {
332
    private static synchronized void setTarget(Writer targetFile) {
333
        if (target == null) {
333
        if (target == null) {
334
            target = getTarget(targetFile, getFormat());
334
            target = getTarget(targetFile, getFormat());
335
            isTargetSystemOut = isWriterSystemOut;
335
            isTargetSystemOut = isWriterSystemOut;
Lines 346-349 Link Here
346
    private static LogTarget getTarget(Writer targetFile, PatternFormatter fmt) {
346
    private static LogTarget getTarget(Writer targetFile, PatternFormatter fmt) {
347
        return new WriterTarget(targetFile, fmt);
347
        return new WriterTarget(targetFile, fmt);
348
    }
348
    }
349
350
    /**
351
     * Add logTarget to root logger
352
     * FIXME What's the clean way to add a LogTarget afterwards ?
353
     * @param logTarget LogTarget
354
     */
355
    public static void addLogTargetToRootLogger(LogTarget logTarget) {
356
        Hierarchy.getDefaultHierarchy().getRootLogger().setLogTargets(
357
                new LogTarget[]{target, logTarget});
358
    }
349
}
359
}
(-)bin/jmeter.properties (+4 lines)
Lines 121-126 Link Here
121
# See https://issues.apache.org/bugzilla/show_bug.cgi?id=52026 for details
121
# See https://issues.apache.org/bugzilla/show_bug.cgi?id=52026 for details
122
# N.B. the laf can be defined in user.properties.
122
# N.B. the laf can be defined in user.properties.
123
123
124
# LoggerPanl display
125
# default:
126
#jmeter.loggerPanel.display=false
127
124
# Toolbar display
128
# Toolbar display
125
# default:
129
# default:
126
#jmeter.toolbar.display=true
130
#jmeter.toolbar.display=true

Return to bug 41788