├── .asf.yaml
├── .flattened-pom.xml
├── .github
└── workflows
│ └── chainsaw.yml
├── .gitignore
├── .mvn
└── jvm.config
├── HOWTOBUILD.txt
├── LICENSE
├── NOTICE
├── README.md
├── RELEASING
├── TODO
├── build.properties.sample
├── doap_chainsaw.rdf
├── pom.xml
├── sign-artifacts.sh
├── spotbugs-exclude.xml
└── src
├── assembly
├── bin.xml
└── standalone.xml
├── changes
└── changes.xml
├── main
├── java
│ └── org
│ │ └── apache
│ │ └── log4j
│ │ ├── ULogger.java
│ │ ├── chainsaw
│ │ ├── AbstractPreferencePanel.java
│ │ ├── ApplicationPreferenceModel.java
│ │ ├── ApplicationPreferenceModelPanel.java
│ │ ├── BasicPrefPanel.java
│ │ ├── ChainsawAppender.java
│ │ ├── ChainsawColumns.java
│ │ ├── ChainsawConstants.java
│ │ ├── ChainsawCyclicBufferTableModel.java
│ │ ├── ChainsawEventBatchListener.java
│ │ ├── ChainsawStarter.java
│ │ ├── ChainsawStatusBar.java
│ │ ├── ChainsawToolBarAndMenus.java
│ │ ├── ChainsawViewer.java
│ │ ├── CheckListCellRenderer.java
│ │ ├── ColumnComparator.java
│ │ ├── CopyEventsToClipboardAction.java
│ │ ├── CyclicBufferList.java
│ │ ├── DockablePanel.java
│ │ ├── EventContainer.java
│ │ ├── EventCountListener.java
│ │ ├── ExpressionRuleContext.java
│ │ ├── JTextComponentFormatter.java
│ │ ├── LogFilePatternLayoutBuilder.java
│ │ ├── LoggingEventWrapper.java
│ │ ├── ModifiableListModel.java
│ │ ├── NewKeyEvent.java
│ │ ├── NewKeyListener.java
│ │ ├── PopupListener.java
│ │ ├── ProgressPanel.java
│ │ ├── ReceiverConfigurationPanel.java
│ │ ├── ReceiverEventListener.java
│ │ ├── RuleMediator.java
│ │ ├── ShutdownListener.java
│ │ ├── ShutdownManager.java
│ │ ├── SortTableModel.java
│ │ ├── TableColorizingRenderer.java
│ │ ├── color
│ │ │ ├── ColorPanel.java
│ │ │ ├── Colorizer.java
│ │ │ └── RuleColorizer.java
│ │ ├── components
│ │ │ ├── about
│ │ │ │ └── ChainsawAbout.java
│ │ │ ├── elements
│ │ │ │ ├── SmallButton.java
│ │ │ │ ├── SmallToggleButton.java
│ │ │ │ ├── TabIconHandler.java
│ │ │ │ └── sorttable
│ │ │ │ │ ├── JSortTable.java
│ │ │ │ │ ├── SortArrowIcon.java
│ │ │ │ │ └── SortHeaderRenderer.java
│ │ │ ├── loggernamepanel
│ │ │ │ ├── LoggerNameListener.java
│ │ │ │ ├── LoggerNameModel.java
│ │ │ │ ├── LoggerNameModelSupport.java
│ │ │ │ └── LoggerNameTreePanel.java
│ │ │ ├── logpanel
│ │ │ │ ├── AutoFilterComboBox.java
│ │ │ │ ├── ColumnNameKeywordMapper.java
│ │ │ │ ├── ElementFactory.java
│ │ │ │ ├── LogPanel.java
│ │ │ │ ├── LogPanelLoggerTreeModel.java
│ │ │ │ ├── LogPanelPreferenceModel.java
│ │ │ │ └── LogPanelPreferencePanel.java
│ │ │ ├── splash
│ │ │ │ ├── ChainsawSplash.java
│ │ │ │ └── SplashViewer.java
│ │ │ ├── tabbedpane
│ │ │ │ ├── ChainsawTabbedPane.java
│ │ │ │ └── SavableTabSetting.java
│ │ │ ├── tutorial
│ │ │ │ ├── Generator.java
│ │ │ │ ├── GeneratorBeanInfo.java
│ │ │ │ ├── RandomWordGenerator.java
│ │ │ │ └── TutorialFrame.java
│ │ │ └── welcome
│ │ │ │ └── WelcomePanel.java
│ │ ├── dnd
│ │ │ └── FileDnDTarget.java
│ │ ├── doc-files
│ │ │ └── Chainsawv2.gif
│ │ ├── file
│ │ │ ├── FileMenu.java
│ │ │ └── FileSaveAction.java
│ │ ├── filter
│ │ │ ├── EventTypeEntryContainer.java
│ │ │ └── FilterModel.java
│ │ ├── help
│ │ │ ├── HelpLocator.java
│ │ │ └── HelpManager.java
│ │ ├── helper
│ │ │ ├── OkCancelPanel.java
│ │ │ ├── SwingHelper.java
│ │ │ └── TableCellEditorFactory.java
│ │ ├── icons
│ │ │ ├── ChainsawIcons.java
│ │ │ ├── LevelIconFactory.java
│ │ │ └── LineIconFactory.java
│ │ ├── layout
│ │ │ ├── DefaultLayoutFactory.java
│ │ │ ├── EventDetailLayout.java
│ │ │ └── LayoutEditorPane.java
│ │ ├── logevents
│ │ │ ├── ChainsawLoggingEvent.java
│ │ │ ├── ChainsawLoggingEventBuilder.java
│ │ │ ├── Level.java
│ │ │ └── LocationInfo.java
│ │ ├── logui
│ │ │ ├── LogUI.java
│ │ │ ├── LogUIPanelBuilder.java
│ │ │ ├── LogUiKeyStrokeCreator.java
│ │ │ └── LogUiReceiversPanel.java
│ │ ├── osx
│ │ │ └── OSXIntegration.java
│ │ ├── prefs
│ │ │ ├── AbstractSettingsEvent.java
│ │ │ ├── LoadSettingsEvent.java
│ │ │ ├── MRUFileList.java
│ │ │ ├── ProfileManager.java
│ │ │ ├── Profileable.java
│ │ │ ├── SaveSettingsEvent.java
│ │ │ ├── SettingsEvent.java
│ │ │ ├── SettingsListener.java
│ │ │ └── SettingsManager.java
│ │ ├── receiver
│ │ │ ├── ChainsawReceiver.java
│ │ │ ├── ChainsawReceiverFactory.java
│ │ │ └── ChainsawReceiverSkeleton.java
│ │ ├── receivers
│ │ │ ├── NewReceiverDialogPanel.java
│ │ │ ├── PluginPropertyEditorPanel.java
│ │ │ ├── ReceiverTreeCellRenderer.java
│ │ │ ├── ReceiversPanel.java
│ │ │ ├── ReceiversTreeModel.java
│ │ │ └── VisualReceiver.java
│ │ ├── vfs
│ │ │ ├── VFSLogFilePatternReceiver.java
│ │ │ ├── VFSLogFilePatternReceiverBeanInfo.java
│ │ │ └── VFSLogFilePatternReceiverFactory.java
│ │ └── zeroconf
│ │ │ ├── ZeroConfDeviceModel.java
│ │ │ ├── ZeroConfPlugin.java
│ │ │ └── ZeroConfPreferenceModel.java
│ │ ├── helpers
│ │ ├── Constants.java
│ │ └── MessageFormatter.java
│ │ ├── net
│ │ ├── AddressBased.java
│ │ ├── ECSLogEvent.java
│ │ ├── JsonReceiver.java
│ │ ├── JsonReceiverFactory.java
│ │ ├── MulticastReceiver.java
│ │ ├── MulticastReceiverBeanInfo.java
│ │ ├── MulticastReceiverFactory.java
│ │ ├── NetworkBased.java
│ │ ├── PortBased.java
│ │ ├── SocketNodeEventListener.java
│ │ ├── UDPReceiver.java
│ │ ├── UDPReceiverFactory.java
│ │ ├── XMLReceiverFactory.java
│ │ └── XMLSocketReceiver.java
│ │ ├── rule
│ │ ├── AbstractRule.java
│ │ ├── AndRule.java
│ │ ├── ColorRule.java
│ │ ├── EqualsRule.java
│ │ ├── ExistsRule.java
│ │ ├── ExpressionRule.java
│ │ ├── InFixToPostFix.java
│ │ ├── InequalityRule.java
│ │ ├── LevelEqualsRule.java
│ │ ├── LevelInequalityRule.java
│ │ ├── LikeRule.java
│ │ ├── NotEqualsRule.java
│ │ ├── NotLevelEqualsRule.java
│ │ ├── NotRule.java
│ │ ├── OrRule.java
│ │ ├── PartialTextMatchRule.java
│ │ ├── Rule.java
│ │ ├── RuleFactory.java
│ │ ├── TimestampEqualsRule.java
│ │ └── TimestampInequalityRule.java
│ │ ├── scheduler
│ │ ├── Job.java
│ │ └── Scheduler.java
│ │ ├── spi
│ │ ├── Decoder.java
│ │ ├── ErrorItem.java
│ │ ├── LoggingEventFieldResolver.java
│ │ ├── NOPULogger.java
│ │ └── SimpleULogger.java
│ │ ├── varia
│ │ ├── LogFilePatternReceiver.java
│ │ ├── LogFilePatternReceiverBeanInfo.java
│ │ └── LogFilePatternReceiverFactory.java
│ │ └── xml
│ │ ├── Log4jEntityResolver.java
│ │ ├── LogFileXMLReceiver.java
│ │ ├── UtilLoggingEntityResolver.java
│ │ ├── UtilLoggingXMLDecoder.java
│ │ └── XMLDecoder.java
└── resources
│ ├── META-INF
│ ├── LICENSE
│ ├── NOTICE
│ └── services
│ │ └── org.apache.log4j.chainsaw.receiver.ChainsawReceiverFactory
│ ├── log4j2.xml
│ ├── logo.icns
│ ├── org
│ └── apache
│ │ └── log4j
│ │ ├── chainsaw
│ │ ├── ChainsawAbout.html
│ │ ├── Details_UDPReceiver.html
│ │ ├── Details_XMLSocketReceiver.html
│ │ ├── WelcomePanel.html
│ │ ├── favourites
│ │ │ └── package.html
│ │ ├── help
│ │ │ ├── release-notes.html
│ │ │ └── tutorial.html
│ │ ├── icons
│ │ │ ├── About16.gif
│ │ │ ├── About24.gif
│ │ │ ├── Back16.gif
│ │ │ ├── Back24.gif
│ │ │ ├── Bean16.gif
│ │ │ ├── Bean24.gif
│ │ │ ├── Copy16.gif
│ │ │ ├── Copy24.gif
│ │ │ ├── Cut16.gif
│ │ │ ├── Cut24.gif
│ │ │ ├── Delete16.gif
│ │ │ ├── Delete24.gif
│ │ │ ├── Down16.gif
│ │ │ ├── Edit16.gif
│ │ │ ├── Edit24.gif
│ │ │ ├── Export16.gif
│ │ │ ├── Export24.gif
│ │ │ ├── Find16.gif
│ │ │ ├── Find24.gif
│ │ │ ├── Forward16.gif
│ │ │ ├── Forward24.gif
│ │ │ ├── Help16.gif
│ │ │ ├── Help24.gif
│ │ │ ├── Home16.gif
│ │ │ ├── Home24.gif
│ │ │ ├── Host16.gif
│ │ │ ├── Host24.gif
│ │ │ ├── Import16.gif
│ │ │ ├── Import24.gif
│ │ │ ├── Information16.gif
│ │ │ ├── Information24.gif
│ │ │ ├── LICENSE
│ │ │ ├── New16.gif
│ │ │ ├── New24.gif
│ │ │ ├── Open16.gif
│ │ │ ├── Open24.gif
│ │ │ ├── Pause16.gif
│ │ │ ├── Pause24.gif
│ │ │ ├── Play16.gif
│ │ │ ├── Play24.gif
│ │ │ ├── Preferences16.gif
│ │ │ ├── Preferences24.gif
│ │ │ ├── Redo16.gif
│ │ │ ├── Redo24.gif
│ │ │ ├── Refresh16.gif
│ │ │ ├── Refresh24.gif
│ │ │ ├── RowInsertAfter16.gif
│ │ │ ├── RowInsertAfter24.gif
│ │ │ ├── SaveAs16.gif
│ │ │ ├── SaveAs24.gif
│ │ │ ├── Server16.gif
│ │ │ ├── Server24.gif
│ │ │ ├── Stop16.gif
│ │ │ ├── Stop24.gif
│ │ │ ├── TipOfTheDay16.gif
│ │ │ ├── TipOfTheDay24.gif
│ │ │ ├── Up16.gif
│ │ │ ├── Zoom16.gif
│ │ │ ├── Zoom24.gif
│ │ │ ├── ZoomIn16.gif
│ │ │ ├── ZoomIn24.gif
│ │ │ ├── ZoomOut16.gif
│ │ │ ├── ZoomOut24.gif
│ │ │ └── channelexplorer_satellite.gif
│ │ ├── layout
│ │ │ ├── DefaultDetailLayout.html
│ │ │ └── FullDetailLayout.html
│ │ ├── log4j-receiver-sample.xml
│ │ ├── logo.png
│ │ ├── package.html
│ │ ├── prefs
│ │ │ ├── default.properties
│ │ │ └── logpanel.properties
│ │ ├── receivers
│ │ │ └── known.receivers
│ │ ├── stylesheet.css
│ │ └── zeroconf
│ │ │ └── ZeroConfPlugin.html
│ │ └── xml
│ │ └── log4j.dtd
│ └── pages
│ ├── about.html
│ ├── img
│ └── logo.png
│ └── stylesheet.css
├── site
├── apt
│ ├── colorizing-output.apt
│ ├── configuration-library.apt
│ ├── distributionnotes.apt
│ ├── expression-rules.apt
│ ├── index.apt
│ ├── quicktour.apt
│ ├── roadmap.apt
│ ├── viewing-log-events.apt
│ └── zeroconf.apt
├── asciidoc
│ └── download.adoc
├── resources
│ ├── css
│ │ ├── maven-base.css
│ │ └── site.css
│ └── images
│ │ ├── chainsaw-1.jpg
│ │ ├── chainsaw-configure-json.png
│ │ ├── chainsaw-log-panel.png
│ │ ├── chainsaw-new-receiver.png
│ │ ├── chainsaw-overview.png
│ │ ├── chainsaw-with-events.png
│ │ ├── chainsaw-with-receiver.png
│ │ ├── chainsaw-with-receivers.png
│ │ ├── color-menu-bar.png
│ │ ├── color-menu-click.png
│ │ ├── color-selection-menu.png
│ │ ├── details-pane.png
│ │ ├── log-pane.png
│ │ ├── logger-pane.png
│ │ ├── logo.png
│ │ └── ls-logo.jpg
├── site.vm
└── site.xml
└── test
├── java
└── org
│ └── apache
│ └── log4j
│ └── xml
│ └── XMLDecoderTest.java
└── resources
└── org
└── apache
└── log4j
├── db
├── append-with-drivermanager1.xml
└── read-with-drivermanager1.xml
├── rewrite
├── map.log
├── map.xml
├── property.log
├── property.xml
├── reflection.log
└── reflection.xml
└── xml
├── xmlLayout.1.xml
└── xsltLayout.1.xml
/.asf.yaml:
--------------------------------------------------------------------------------
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 | notifications:
19 | jira_options: link label
20 |
21 | github:
22 | description: "Apache Chainsaw is a GUI log viewer"
23 | homepage: http://logging.apache.org/chainsaw
24 | labels:
25 | - apache
26 | - logging
27 | - java
28 | features:
29 | issues: true
30 |
--------------------------------------------------------------------------------
/.github/workflows/chainsaw.yml:
--------------------------------------------------------------------------------
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 | name: chainsaw
18 |
19 | on: [push, pull_request]
20 |
21 | jobs:
22 | build:
23 |
24 | runs-on: ${{ matrix.os }}
25 |
26 | strategy:
27 | matrix:
28 | os: [ macos-latest ]
29 |
30 | steps:
31 |
32 | - name: Checkout repository
33 | uses: actions/checkout@v2
34 |
35 | # JDK 11 is needed for the build.
36 | # Search `maven-toolchains-plugin` usages for details.
37 | - name: Setup JDK 11
38 | uses: actions/setup-java@v2.4.0
39 | with:
40 | distribution: temurin
41 | java-version: 17
42 | java-package: jdk
43 | architecture: x64
44 | cache: maven
45 |
46 | - name: Inspect environment (Linux)
47 | if: runner.os == 'Linux'
48 | run: env | grep '^JAVA'
49 |
50 | - name: Inspect environment (Windows)
51 | if: runner.os == 'Windows'
52 | run: set java
53 |
54 | - name: Inspect environment (MacOS)
55 | if: runner.os == 'macOS'
56 | run: env | grep '^JAVA'
57 |
58 | - name: Maven "build"
59 | timeout-minutes: 60
60 | shell: bash
61 | run: |
62 | mvn site:site
63 | mvn install
64 |
65 | # - name: archive dmg
66 | # timeout-minutes: 60
67 | # shell: bash
68 | # run: find target -name \*.dmg
69 | #
70 | # - uses: actions/upload-artifact@v3
71 | # with:
72 | # name: chainsaw.dmg
73 | # path: target/*.dmg
74 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .classpath
3 | .project
4 | .idea/
5 | *.iml
6 | .DS_Store
7 | *.swp
8 | /.settings/
9 |
--------------------------------------------------------------------------------
/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2 | --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3 | --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
4 | --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
5 | --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
6 | --add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
7 | --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8 | --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
9 | --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
10 | --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
11 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache Chainsaw
2 | Copyright 2007-2023 The Apache Software Foundation
3 |
4 | This product includes software developed by
5 | The Apache Software Foundation (http://www.apache.org/).
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
17 |
18 | # Apache Chainsaw
19 |
20 | Apache Chainsaw is a GUI log file viewer
21 |
22 | More information can be found on the Chainsaw website: http://logging.apache.org/chainsaw/2.x/
23 |
24 | ## Starting
25 |
26 | Please start the ChainsawStarter class, which has a main method.
27 |
28 | ## Issue tracking
29 |
30 | We have been using Jira in the past:
31 | https://issues.apache.org/jira/browse/CHAINSAW
32 |
33 | The current issue tracker is hosted by GitHub:
34 | https://github.com/apache/logging-chainsaw/issues
35 |
--------------------------------------------------------------------------------
/RELEASING:
--------------------------------------------------------------------------------
1 |
17 |
18 | https://cwiki.apache.org/confluence/display/LOGGING/Chainsaw+Release+Guide
19 |
--------------------------------------------------------------------------------
/build.properties.sample:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | # Chainsaw requires the following jars to build and run:
17 | # * Jakarta Commons VFS 1.0 RC1+ (requires sub-dependecy of Jakarta Commons Logging).
18 | # * XStream - http://xstream.codehaus.org (BSD License)
19 | # * Log4j 1.3 jars
20 | #
21 | # Place the Jars in a local 'lib' folder, and Chainsaw should compile and run
22 | #
23 | # Jakarta Commons VFS Required if you wish to compile and include the
24 | # org.apache.log4j.chainsaw.vfs.VFSLogFilePatternReceiver virtual file system receiver
25 | # to access log files in Chainsaw, but is optional.
26 | #
27 | # See http://jakarta.apache.org/commons/sandbox/vfs/filesystems.html
28 | # for a full description of supported file systems (ssh, zip, etc).
29 | #
30 | # See http://jakarta.apache.org/commons/sandbox/vfs/download.html for
31 | # file system-specific jars required when running Chainsaw with a VFSLogFilePatternReceiver
32 | #
33 | # NOTE: VFS requires Commons logging JAR to run
34 |
35 | # Dependencies directory
36 | deps.dir=lib
37 |
38 | # The location of the log4j source code (unpacked), required if you want to build the HTML JavaDoc for the Receivers
39 | # into the Chainsaw GUI. This is a MUST for building the complete distribution
40 | log4j.src=../log4j/
41 |
--------------------------------------------------------------------------------
/doap_chainsaw.rdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
25 |
26 | 2007-02-09
27 |
28 | Apache Chainsaw
29 |
30 |
31 | Apache Chainsaw is a GUI log viewer.
32 |
33 |
34 |
35 | Java
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/sign-artifacts.sh:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | #!/bin/bash
17 |
18 | # script to generate .asc, .md5, and .sha512 files for built artifacts
19 |
20 | if [[ $# -ne 1 ]]
21 | then
22 | echo "Usage: $0 gpg-key-id"
23 | exit 1
24 | fi
25 |
26 | GPG_KEY="$1"
27 |
28 | cd target
29 | for f in apache-chainsaw-*-bin.* apache-chainsaw-*-standalone.* apache-chainsaw-*-src.*
30 | do
31 | gpg --default-key="$GPG_KEY" --sign --detach-sign --armor "$f"
32 | shasum -a 512 "$f" >"$f.sha512"
33 | done
34 |
--------------------------------------------------------------------------------
/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/assembly/bin.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
23 | bin
24 |
25 | zip
26 | tar.gz
27 |
28 | true
29 |
30 |
31 |
32 |
33 |
34 |
35 | LICENSE
36 | NOTICE
37 | build.xml
38 | pom.xml
39 | src/**
40 |
41 |
42 |
43 | target
44 | .
45 |
46 | apache-chainsaw-${project.version}.jar
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/assembly/standalone.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 | standalone
20 |
21 | zip
22 | tar.gz
23 |
24 | true
25 |
26 |
27 | target/appassembler/bin
28 | bin
29 | unix
30 | 0755
31 | 0755
32 |
33 |
34 | target/appassembler/repo
35 | repo
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/BasicPrefPanel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import javax.swing.*;
20 |
21 | /**
22 | * All of the Preferences panels used in this class extend from
23 | * this, it is used to provide standard L&F required by all.
24 | *
25 | * @author Paul Smith
26 | */
27 | public abstract class BasicPrefPanel extends JPanel {
28 | private String title;
29 |
30 | protected BasicPrefPanel(String title) {
31 | this.title = title;
32 | }
33 |
34 | /**
35 | * @return Returns the title.
36 | */
37 | public final String getTitle() {
38 | return title;
39 | }
40 |
41 | /**
42 | * @param title The title to set.
43 | */
44 | public final void setTitle(String title) {
45 | this.title = title;
46 | }
47 |
48 | public String toString() {
49 | return getTitle();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ChainsawAppender.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.time.Instant;
20 | import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEventBuilder;
21 | import org.apache.log4j.chainsaw.receiver.ChainsawReceiver;
22 | import org.apache.log4j.chainsaw.receiver.ChainsawReceiverSkeleton;
23 | import org.apache.logging.log4j.core.LogEvent;
24 | import org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender;
25 | import org.apache.logging.log4j.core.config.plugins.Plugin;
26 | import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
27 | import org.apache.logging.log4j.core.config.plugins.PluginFactory;
28 |
29 | @Plugin(name = "ChainsawAppender", category = "Core", elementType = "appender", printObject = true)
30 | public final class ChainsawAppender extends AbstractOutputStreamAppender {
31 |
32 | private ChainsawAppenderReceiver receiver = new ChainsawAppenderReceiver();
33 |
34 | private ChainsawAppender(String name) {
35 | super(name, null, null, true, true, null);
36 | }
37 |
38 | @PluginFactory
39 | public static ChainsawAppender createAppender(@PluginAttribute("name") String name) {
40 | System.out.println("create the chainsaw appender");
41 |
42 | if (name == null) {
43 | LOGGER.error("No name provided for ChainsawAppender");
44 | return null;
45 | }
46 |
47 | return new ChainsawAppender(name);
48 | }
49 |
50 | @Override
51 | public void append(final LogEvent event) {
52 | ChainsawLoggingEventBuilder builder = new ChainsawLoggingEventBuilder();
53 |
54 | builder.setLevelFromString(event.getLevel().name())
55 | .setLogger(event.getLoggerName())
56 | .setMessage(event.getMessage().getFormattedMessage())
57 | .setThreadName(event.getThreadName())
58 | .setTimestamp(Instant.ofEpochMilli(event.getInstant().getEpochMillisecond()));
59 |
60 | receiver.append(builder.create());
61 | }
62 |
63 | public ChainsawReceiver getReceiver() {
64 | return receiver;
65 | }
66 |
67 | class ChainsawAppenderReceiver extends ChainsawReceiverSkeleton {
68 |
69 | @Override
70 | public void start() {}
71 |
72 | @Override
73 | public void shutdown() {}
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ChainsawColumns.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.*;
20 | import java.util.ArrayList;
21 | import java.util.List;
22 | import javax.swing.*;
23 | import org.apache.log4j.chainsaw.icons.ChainsawIcons;
24 |
25 | /**
26 | * @author Paul Smith <psmith@apache.org>
27 | */
28 | public class ChainsawColumns {
29 | private static final List columnNames = new ArrayList<>();
30 |
31 | static {
32 | columnNames.add(ChainsawConstants.TIMESTAMP_COL_NAME);
33 | columnNames.add(ChainsawConstants.LOG4J_MARKER_COL_NAME);
34 | columnNames.add(ChainsawConstants.LEVEL_COL_NAME);
35 | columnNames.add(ChainsawConstants.LOGGER_COL_NAME);
36 | columnNames.add(ChainsawConstants.MESSAGE_COL_NAME);
37 |
38 | // NOTE: ID must ALWAYS be last field because the model adds this value itself as an identifier to the end of
39 | // the consructed vector
40 | columnNames.add(ChainsawConstants.ID_COL_NAME);
41 | }
42 |
43 | public static final int INDEX_TIMESTAMP_COL_NAME = 1;
44 | public static final int INDEX_LOG4J_MARKER_COL_NAME = 2;
45 | public static final int INDEX_LEVEL_COL_NAME = 3;
46 | public static final int INDEX_LOGGER_COL_NAME = 4;
47 | public static final int INDEX_MESSAGE_COL_NAME = 5;
48 | public static final int INDEX_ID_COL_NAME = 6;
49 |
50 | public static final Cursor CURSOR_FOCUS_ON;
51 |
52 | static {
53 | CURSOR_FOCUS_ON = Toolkit.getDefaultToolkit()
54 | .createCustomCursor(new ImageIcon(ChainsawIcons.WINDOW_ICON).getImage(), new Point(3, 3), "FocusOn");
55 | }
56 |
57 | private ChainsawColumns() {}
58 |
59 | public static List getColumnsNames() {
60 | return columnNames;
61 | }
62 |
63 | /**
64 | * Given the index which matches one of the static constants in this class, returns the resolved
65 | * Column name as a string label.
66 | *
67 | * @param columnIndex (note this is a 1 based collection)
68 | * @return column name
69 | */
70 | public static String getColumnName(int columnIndex) {
71 | return getColumnsNames().get(columnIndex - 1).toString();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ChainsawEventBatchListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.util.List;
20 | import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
21 |
22 | /**
23 | *
24 | */
25 | public interface ChainsawEventBatchListener {
26 | void receiveChainsawEventBatch(List events);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ChainsawViewer.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | /**
20 | * Chainsaw compatible gui viewers must implement this interface
21 | * in order to be opened and configured by the ChainsawAppender class.
22 | *
23 | * @author Mark Womack
24 | */
25 | public interface ChainsawViewer {
26 | /**
27 | * Called when the viewer should activate.
28 | *
29 | * @param model The ChainsawAppender model instance the viewer should use.
30 | */
31 | void activateViewer(ChainsawAppender model);
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/CheckListCellRenderer.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.*;
20 | import javax.swing.*;
21 | import javax.swing.border.Border;
22 | import javax.swing.table.TableColumn;
23 |
24 | /**
25 | * A ListCellRenderer that display a check box if the value
26 | * has been "checked".
27 | *
28 | * Borrowed heavily from the excellent book "Swing, 2nd Edition" by
29 | * Matthew Robinson & Pavel Vorobiev.
30 | *
31 | * @author Paul Smith
32 | */
33 | public abstract class CheckListCellRenderer extends JCheckBox implements ListCellRenderer {
34 | private final Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
35 |
36 | /**
37 | *
38 | */
39 | public CheckListCellRenderer() {
40 | super();
41 | setOpaque(true);
42 | setBorder(noFocusBorder);
43 | }
44 |
45 | /* (non-Javadoc)
46 | * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
47 | */
48 | public Component getListCellRendererComponent(
49 | JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
50 | setText(((TableColumn) value).getHeaderValue().toString());
51 | setBackground(isSelected ? list.getSelectionBackground() : list.getBackground());
52 | setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());
53 | setFont(list.getFont());
54 | setBorder(cellHasFocus ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
55 |
56 | setSelected(isSelected(value));
57 | return this;
58 | }
59 |
60 | /**
61 | * @param value
62 | * @return selected flag
63 | */
64 | protected abstract boolean isSelected(Object value);
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/CopyEventsToClipboardAction.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.*;
20 | import java.awt.datatransfer.StringSelection;
21 | import java.awt.event.ActionEvent;
22 | import java.util.List;
23 | import javax.swing.*;
24 | import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
25 | import org.apache.log4j.chainsaw.logui.LogUI;
26 |
27 | public class CopyEventsToClipboardAction extends AbstractAction {
28 |
29 | private static final long serialVersionUID = 1L;
30 | private static final int EVENTSIZE_FUDGE_FACTOR = 128; // guestimate 128 chars per event
31 | private final LogUI logUi;
32 |
33 | /**
34 | * Layout pattern uses a simple but concise format that reads well and has a fixed size set of
35 | * useful columns before the message. Nice format for pasting into issue trackers.
36 | */
37 | // private final Layout layout = new EnhancedPatternLayout(
38 | // "[%d{ISO8601} %-5p][%20.20c][%t] %m%n");
39 |
40 | public CopyEventsToClipboardAction(LogUI parent) {
41 | super("Copy events to clipboard");
42 | this.logUi = parent;
43 |
44 | putValue(
45 | Action.SHORT_DESCRIPTION,
46 | "Copies to the clipboard currently visible events to a human-readable, log-like format");
47 | }
48 |
49 | public void actionPerformed(ActionEvent e) {
50 | List filteredEvents = logUi.getCurrentLogPanel().getFilteredEvents();
51 | StringBuilder writer = new StringBuilder(filteredEvents.size() * EVENTSIZE_FUDGE_FACTOR);
52 | for (Object filteredEvent : filteredEvents) {
53 | ChainsawLoggingEvent event = ((LoggingEventWrapper) filteredEvent).getLoggingEvent();
54 | writer.append(event.m_message);
55 | }
56 |
57 | StringSelection stringSelection = new StringSelection(writer.toString());
58 | Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, stringSelection);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/DockablePanel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.*;
20 | import javax.swing.*;
21 |
22 | /**
23 | * Extends the functionality of a JPanel by providing a 'docked' state.
24 | *
25 | * @author Scott Deboy <sdeboy@apache.org>
26 | * @author Paul Smith <psmith@apache.org>
27 | */
28 | public class DockablePanel extends JPanel {
29 | private boolean isDocked = true;
30 |
31 | public void setDocked(boolean docked) {
32 | boolean oldVal = isDocked;
33 | isDocked = docked;
34 | firePropertyChange("docked", oldVal, isDocked);
35 | }
36 |
37 | public boolean isDocked() {
38 | return isDocked;
39 | }
40 |
41 | public Dimension getPreferredSize() {
42 | return new Dimension(1024, 768);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/EventCountListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.util.EventListener;
20 |
21 | /**
22 | * Listeners can be notified when the # of events in a particular model
23 | * changes
24 | *
25 | * @author Scott Deboy <sdeboy@apache.org>
26 | */
27 | public interface EventCountListener extends EventListener {
28 | void eventCountChanged(int currentCount, int totalCount);
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/JTextComponentFormatter.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.*;
20 | import javax.swing.*;
21 | import javax.swing.text.Document;
22 | import javax.swing.text.JTextComponent;
23 | import javax.swing.text.html.HTMLDocument;
24 |
25 | /**
26 | * Apply system font and size (normal size + 1) rule if the JEditorPane document contains html.
27 | */
28 | public class JTextComponentFormatter {
29 | public static void applySystemFontAndSize(JTextComponent textComponent) {
30 | Document document = textComponent.getDocument();
31 | if (document instanceof HTMLDocument) {
32 | Font font = UIManager.getFont("Label.font");
33 | String bodyRule =
34 | "body { font-family: " + font.getFamily() + "; font-size: " + (font.getSize() + 1) + "pt; }";
35 | ((HTMLDocument) document).getStyleSheet().addRule(bodyRule);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ModifiableListModel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import javax.swing.*;
20 |
21 | /**
22 | * @author Paul Smith <psmith@apache.org>
23 | */
24 | public class ModifiableListModel extends DefaultListModel {
25 | public void fireContentsChanged() {
26 | fireContentsChanged(this, 0, this.size());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/NewKeyEvent.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.util.EventObject;
20 |
21 | /**
22 | * An event representing when a Key has arrived inside a Chainsaw model that has
23 | * not been seen previously.
24 | *
25 | * @author Paul Smith <psmith@apache.org>
26 | */
27 | public class NewKeyEvent extends EventObject {
28 | private final int newModelIndex;
29 | private final Object key;
30 | private final Object value;
31 |
32 | public NewKeyEvent(Object source, int newModelIndex, Object key, Object value) {
33 | super(source);
34 | this.newModelIndex = newModelIndex;
35 | this.key = key;
36 | this.value = value;
37 | }
38 |
39 | public Object getKey() {
40 | return key;
41 | }
42 |
43 | public int getNewModelIndex() {
44 | return newModelIndex;
45 | }
46 |
47 | public Object getValue() {
48 | return value;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/NewKeyListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.util.EventListener;
20 |
21 | /**
22 | * Interested parties are notified when a MDC/Property key has arrived
23 | * that has not been seen before by the source Model
24 | *
25 | * @author Paul Smith
26 | */
27 | public interface NewKeyListener extends EventListener {
28 |
29 | /**
30 | * @param e the new key event being added
31 | */
32 | void newKeyAdded(NewKeyEvent e);
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/PopupListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.event.MouseAdapter;
20 | import java.awt.event.MouseEvent;
21 | import javax.swing.*;
22 |
23 | /**
24 | * Ensures that a specific popupMenu is displayed when the relevant
25 | * mouse events are trapped.
26 | *
27 | * @author Scott Deboy <sdeboy@apache.org>
28 | * @author Paul Smith <psmith@apache.org>
29 | */
30 | public class PopupListener extends MouseAdapter {
31 | final JPopupMenu popupMenu;
32 |
33 | public PopupListener(JPopupMenu popupMenu) {
34 | this.popupMenu = popupMenu;
35 | }
36 |
37 | @Override
38 | public void mousePressed(MouseEvent e) {
39 | checkPopup(e);
40 | }
41 |
42 | @Override
43 | public void mouseReleased(MouseEvent e) {
44 | checkPopup(e);
45 | }
46 |
47 | @Override
48 | public void mouseClicked(MouseEvent e) {
49 | checkPopup(e);
50 | }
51 |
52 | private void checkPopup(MouseEvent e) {
53 | if (e.isPopupTrigger()) {
54 | popupMenu.show(e.getComponent(), e.getX(), e.getY());
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ProgressPanel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.awt.*;
20 | import java.lang.reflect.InvocationTargetException;
21 | import javax.swing.*;
22 |
23 | /**
24 | * A simple ProgressPanel that can be used, a little more flexible
25 | * than ProgressMonitor when you want it to be shown REGARDLESS
26 | * of any timeouts etc.
27 | *
28 | * @author Paul Smith <psmith@apache.org>
29 | */
30 | public class ProgressPanel extends JPanel {
31 | private final JLabel messageLabel = new JLabel();
32 | private final JProgressBar progressBar;
33 |
34 | ProgressPanel(int min, int max, String msg) {
35 | this.progressBar = new JProgressBar(min, max);
36 | setBorder(BorderFactory.createLineBorder(Color.black, 1));
37 | messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
38 | messageLabel.setText(msg);
39 | setLayout(new BorderLayout());
40 |
41 | add(progressBar, BorderLayout.CENTER);
42 | add(messageLabel, BorderLayout.SOUTH);
43 | }
44 |
45 | public void setMessage(final String string) {
46 | SwingUtilities.invokeLater(() -> messageLabel.setText(string));
47 | }
48 |
49 | public void setProgress(final int progress) {
50 | try {
51 | Runnable runnable = () -> progressBar.setValue(progress);
52 | if (!SwingUtilities.isEventDispatchThread()) {
53 | SwingUtilities.invokeAndWait(runnable);
54 | } else {
55 | runnable.run();
56 | }
57 | } catch (InterruptedException | InvocationTargetException e) {
58 | // TODO Auto-generated catch block
59 | e.printStackTrace();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ReceiverEventListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import org.apache.log4j.chainsaw.receiver.ChainsawReceiver;
20 |
21 | /**
22 | * A ReceiverEventListener is an interface that lets you listen to events, such
23 | * as receivers being added or removed.
24 | */
25 | public interface ReceiverEventListener {
26 |
27 | public void receiverAdded(ChainsawReceiver rx);
28 |
29 | public void receiverRemoved(ChainsawReceiver rx);
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/ShutdownListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import java.util.EventListener;
20 | import org.apache.log4j.chainsaw.logui.LogUI;
21 |
22 | /**
23 | * Chainsaw notifies these Listeners when the user has requested
24 | * it to shutdown.
25 | *
26 | * Listeners should use this opportunity to release any resources
27 | * and/or perform any clean up activity.
28 | *
29 | * Listeners should NOT perform the action of actual shutting down
30 | * however (i.e. do not call System.exit()).
31 | *
32 | * @author Paul Smith <psmith@apache.org>
33 | * @see LogUI#addShutdownListener(ShutdownListener)
34 | */
35 | public interface ShutdownListener extends EventListener {
36 |
37 | void shuttingDown();
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/SortTableModel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw;
18 |
19 | import javax.swing.table.TableModel;
20 |
21 | /**
22 | * An extended TableModel interface that allows Column sorting
23 | *
24 | * @author Claude Duguay
25 | */
26 | public interface SortTableModel extends TableModel {
27 | void sortColumn(int col, boolean ascending);
28 |
29 | void sort();
30 |
31 | boolean isSortable(int col);
32 |
33 | boolean isSortEnabled();
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/color/Colorizer.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.color;
18 |
19 | import java.awt.Color;
20 | import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
21 |
22 | /**
23 | * Given a LoggingEvent, can determine an appropriate
24 | * Color to use based on whatever this implementation
25 | * has been coded.
26 | *
27 | * @author Paul Smith <psmith@apache.org>
28 | * @author Scott Deboy <sdeboy@apache.org>
29 | */
30 | public interface Colorizer {
31 | /**
32 | * Given a LoggingEvent, returns a Color to use for background,
33 | * or null if this instance cannot determine one, or that
34 | * the standard color should be used.
35 | *
36 | * @param event the ChainsawLoggingEvent
37 | * @return background color or null
38 | */
39 | Color getBackgroundColor(ChainsawLoggingEvent event);
40 |
41 | Color getForegroundColor(ChainsawLoggingEvent event);
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/elements/sorttable/SortArrowIcon.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.elements.sorttable;
18 |
19 | import java.awt.*;
20 | import javax.swing.*;
21 |
22 | /**
23 | * An Icon that is a Nice arrow to be used for displaying which
24 | * Column is being used for sorting.
25 | *
26 | * @author Claude Duguay
27 | */
28 | public class SortArrowIcon implements Icon {
29 | public static final int NONE = 0;
30 | public static final int DECENDING = 1;
31 | public static final int ASCENDING = 2;
32 | protected int direction;
33 | protected int width = 8;
34 | protected int height = 8;
35 |
36 | public SortArrowIcon(int direction) {
37 | this.direction = direction;
38 | }
39 |
40 | public int getIconWidth() {
41 | return width;
42 | }
43 |
44 | public int getIconHeight() {
45 | return height;
46 | }
47 |
48 | public void paintIcon(Component c, Graphics g, int x, int y) {
49 | Color bg = c.getBackground();
50 | Color light = bg.brighter();
51 | Color shade = bg.darker();
52 |
53 | int w = width;
54 | int h = height;
55 | int m = w / 2;
56 |
57 | if (direction == ASCENDING) {
58 | g.setColor(shade);
59 | g.drawLine(x, y, x + w, y);
60 | g.drawLine(x, y, x + m, y + h);
61 | g.setColor(light);
62 | g.drawLine(x + w, y, x + m, y + h);
63 | }
64 |
65 | if (direction == DECENDING) {
66 | g.setColor(shade);
67 | g.drawLine(x + m, y, x, y + h);
68 | g.setColor(light);
69 | g.drawLine(x, y + h, x + w, y + h);
70 | g.drawLine(x + m, y, x + w, y + h);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/loggernamepanel/LoggerNameListener.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.loggernamepanel;
18 |
19 | import java.util.EventListener;
20 |
21 | /**
22 | * Implementations are notified when new Logger names
23 | * are added to the related LoggerNameModel instance.
24 | *
25 | * @author Paul Smith <psmith@apache.org>
26 | */
27 | public interface LoggerNameListener extends EventListener {
28 | /**
29 | * Called by LoggerNameModel instances when a new unique
30 | * Logger name string has been introduced into the model
31 | *
32 | * @param loggerName the new, unique loggerName
33 | */
34 | void loggerNameAdded(String loggerName);
35 |
36 | /**
37 | * Logger names were reset (used to clear the tree model)
38 | */
39 | void reset();
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/loggernamepanel/LoggerNameModel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.loggernamepanel;
18 |
19 | import java.util.Collection;
20 |
21 | /**
22 | * Implementations of this model contain all the known Logger
23 | * names within it's model space.
24 | *
25 | * @author Paul Smith psmith@apache.org
26 | */
27 | public interface LoggerNameModel {
28 |
29 | /**
30 | * Returns an unmodifiable Collection of the uniquely
31 | * known LoggerNames within this model.
32 | *
33 | * @return unmodifiable Collection of Logger name Strings
34 | */
35 | Collection getLoggerNames();
36 |
37 | /**
38 | * Attempts to add the loggerName to the model, and returns
39 | * true if it does, i.e that the loggerName is new, otherwise
40 | * it is ignored.
41 | *
42 | * If the loggerName is new for this model, all the LoggerNameListeners
43 | * are notified using this thread.
44 | *
45 | * @param loggerName the logger name to add
46 | */
47 | boolean addLoggerName(String loggerName);
48 |
49 | /**
50 | * The logger names have been cleared
51 | */
52 | void reset();
53 |
54 | void addLoggerNameListener(LoggerNameListener l);
55 |
56 | void removeLoggerNameListener(LoggerNameListener l);
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/logpanel/ElementFactory.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.logpanel;
18 |
19 | import java.awt.event.InputEvent;
20 | import java.awt.event.KeyEvent;
21 | import javax.swing.*;
22 | import org.apache.log4j.chainsaw.components.elements.SmallButton;
23 | import org.apache.log4j.chainsaw.icons.ChainsawIcons;
24 |
25 | public class ElementFactory {
26 | public static SmallButton createFindNextButton(Runnable action) {
27 | SmallButton button = new SmallButton.Builder()
28 | .action(action)
29 | .name("Find next")
30 | .text("")
31 | .smallIconUrl(ChainsawIcons.DOWN)
32 | .shortDescription("Find the next occurrence of the rule from the current row")
33 | .keyStroke(KeyStroke.getKeyStroke("F3"))
34 | .build();
35 |
36 | button.getActionMap().put(button.getActionName(), button.getAction());
37 | button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
38 | .put(button.getActionAcceleratorKey(), button.getActionName());
39 | return button;
40 | }
41 |
42 | public static SmallButton createFindPreviousButton(Runnable action) {
43 | SmallButton button = new SmallButton.Builder()
44 | .action(action)
45 | .name("Find previous")
46 | .text("")
47 | .smallIconUrl(ChainsawIcons.UP)
48 | .shortDescription("Find the previous occurrence of the rule from the current row")
49 | .keyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_MASK))
50 | .build();
51 |
52 | button.getActionMap().put(button.getActionName(), button.getAction());
53 | button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
54 | .put(button.getActionAcceleratorKey(), button.getActionName());
55 | return button;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/splash/SplashViewer.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.splash;
18 |
19 | import java.awt.*;
20 | import org.apache.log4j.chainsaw.helper.SwingHelper;
21 |
22 | public class SplashViewer {
23 | private ChainsawSplash splash;
24 |
25 | public void showSplash(Frame owner) {
26 | splash = new ChainsawSplash(owner);
27 | SwingHelper.centerOnScreen(splash);
28 | splash.setVisible(true);
29 | }
30 |
31 | public void removeSplash() {
32 | if (splash != null) {
33 | splash.setVisible(false);
34 | splash.dispose();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/tabbedpane/SavableTabSetting.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.tabbedpane;
18 |
19 | /**
20 | * This class is used to in saving and loading the tab settings
21 | * of Chainsaw....
22 | */
23 | public class SavableTabSetting {
24 | private boolean welcome = false;
25 | private boolean chainsawLog = false;
26 | private boolean zeroConf = false;
27 | // not used currently, but leaving it here to prevent xstream exception for older clients
28 | private boolean dragdrop = false;
29 |
30 | public void setWelcome(boolean welcome) {
31 | this.welcome = welcome;
32 | }
33 |
34 | public void setChainsawLog(boolean chainsawLog) {
35 | this.chainsawLog = chainsawLog;
36 | }
37 |
38 | public void setZeroconf(boolean zeroConf) {
39 | this.zeroConf = zeroConf;
40 | }
41 |
42 | public boolean isWelcome() {
43 | return welcome;
44 | }
45 |
46 | public boolean isChainsawLog() {
47 | return chainsawLog;
48 | }
49 |
50 | public boolean isZeroconf() {
51 | return zeroConf;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/tutorial/GeneratorBeanInfo.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.tutorial;
18 |
19 | import java.beans.PropertyDescriptor;
20 | import java.beans.SimpleBeanInfo;
21 |
22 | /**
23 | * A BeanInfo class to be used as meta-data about the
24 | * Generator plugin
25 | *
26 | * @author Paul Smith <psmith@apache.org>
27 | */
28 | public class GeneratorBeanInfo extends SimpleBeanInfo {
29 | /* (non-Javadoc)
30 | * @see java.beans.BeanInfo#getPropertyDescriptors()
31 | */
32 | public PropertyDescriptor[] getPropertyDescriptors() {
33 | try {
34 | return new PropertyDescriptor[] {
35 | new PropertyDescriptor("name", Generator.class),
36 | };
37 | } catch (Exception e) {
38 | }
39 |
40 | return null;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/components/tutorial/RandomWordGenerator.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.components.tutorial;
18 |
19 | import java.security.SecureRandom;
20 |
21 | public class RandomWordGenerator {
22 | SecureRandom random = new SecureRandom();
23 | private final String[] SYLLABLES = {
24 | "can", "cen", "cin", "con", "cun",
25 | "na", "ne", "ni", "no", "nu",
26 | "ta", "te", "ti", "to", "tu",
27 | "la", "le", "li", "lo", "lu",
28 | "ma", "me", "mi", "mo", "mu",
29 | "ra", "re", "ri", "ro", "ru",
30 | "da", "de", "di", "do", "du",
31 | "fa", "fe", "fi", "fo", "fu",
32 | "sa", "se", "fi", "so", "su"
33 | };
34 |
35 | public String generateWord(int length) {
36 | StringBuilder word = new StringBuilder(length);
37 | for (int i = 0; i < length; i++) {
38 | word.append(SYLLABLES[random.nextInt(SYLLABLES.length)]);
39 | }
40 | return word.toString();
41 | }
42 |
43 | public String generateSentence(int words) {
44 | StringBuilder sentence = new StringBuilder(words);
45 | for (int i = 0; i < words; i++) {
46 | int randomSyllables = random.nextInt(6) + 2; // 2-7 syllabiles
47 | sentence.append(generateWord(randomSyllables)).append(" ");
48 | }
49 | return sentence.toString().trim();
50 | }
51 |
52 | public String generateSentence() {
53 | int words = random.nextInt(12) + 4;
54 | return generateSentence(words);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/doc-files/Chainsawv2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/logging-chainsaw/4e0d5a6aa0241ecf85bdca2f960ca8ca09ae4ccb/src/main/java/org/apache/log4j/chainsaw/doc-files/Chainsawv2.gif
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/filter/FilterModel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.filter;
18 |
19 | import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
20 | import org.apache.log4j.chainsaw.logevents.LocationInfo;
21 |
22 | /**
23 | * This class is used as a Model for Filtering, and retains the unique entries that
24 | * come through over a set of LoggingEvents
25 | *
26 | * @author Paul Smith <psmith@apache.org>
27 | * @author Scott Deboy <sdeboy@apache.org>
28 | */
29 | public class FilterModel {
30 | private EventTypeEntryContainer eventContainer = new EventTypeEntryContainer();
31 |
32 | public void processNewLoggingEvent(ChainsawLoggingEvent event) {
33 |
34 | eventContainer.addLevel(event.m_level);
35 | eventContainer.addLogger(event.m_logger);
36 | eventContainer.addThread(event.m_threadName);
37 | eventContainer.addNDC(event.m_ndc);
38 | eventContainer.addProperties(event.getProperties());
39 |
40 | LocationInfo info = event.m_locationInfo;
41 | if (info != null) {
42 | eventContainer.addClass(info.className);
43 | eventContainer.addMethod(info.methodName);
44 | eventContainer.addFileName(info.fileName);
45 | }
46 | }
47 |
48 | public EventTypeEntryContainer getContainer() {
49 | return eventContainer;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/helper/OkCancelPanel.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.helper;
18 |
19 | import java.awt.*;
20 | import javax.swing.*;
21 |
22 | public class OkCancelPanel extends JPanel {
23 | private final JButton cancelButton = new JButton(" Cancel ");
24 | private final JButton okButton = new JButton(" OK ");
25 |
26 | public OkCancelPanel() {
27 | setLayout(new GridBagLayout());
28 |
29 | cancelButton.setDefaultCapable(true);
30 |
31 | GridBagConstraints c = new GridBagConstraints();
32 |
33 | c.fill = GridBagConstraints.HORIZONTAL;
34 | c.weightx = 1.0;
35 |
36 | add(Box.createHorizontalGlue(), c);
37 |
38 | c.insets = new Insets(5, 5, 5, 5);
39 | c.weightx = 0.0;
40 | c.fill = GridBagConstraints.NONE;
41 | c.anchor = GridBagConstraints.SOUTHEAST;
42 |
43 | add(okButton, c);
44 | add(cancelButton, c);
45 | // add(Box.createHorizontalStrut(6));
46 | }
47 |
48 | /**
49 | * @return Returns the cancelButton.
50 | */
51 | public final JButton getCancelButton() {
52 | return cancelButton;
53 | }
54 |
55 | /**
56 | * @return Returns the okButton.
57 | */
58 | public final JButton getOkButton() {
59 | return okButton;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/helper/TableCellEditorFactory.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.helper;
18 |
19 | import javax.swing.*;
20 | import javax.swing.table.TableCellEditor;
21 | import org.apache.log4j.chainsaw.logevents.Level;
22 |
23 | /**
24 | * @author Paul Smith <psmith@apache.org>
25 | */
26 | public class TableCellEditorFactory {
27 |
28 | /**
29 | * Creates a TableCellEditor to be used for editing boolean values
30 | *
31 | * @return TableCellEditor
32 | */
33 | public static final TableCellEditor createBooleanTableCellEditor() {
34 |
35 | JComboBox comboBox = new JComboBox<>(new Boolean[] {Boolean.TRUE, Boolean.FALSE});
36 | return new DefaultCellEditor(comboBox);
37 | }
38 |
39 | /**
40 | *
41 | */
42 | private TableCellEditorFactory() {}
43 |
44 | /**
45 | * @return table cell editor
46 | */
47 | public static Object createLevelTableCellEditor() {
48 | JComboBox comboBox = new JComboBox<>(new Level[] {
49 | Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL, Level.OFF, Level.ALL
50 | });
51 | return new DefaultCellEditor(comboBox);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/icons/LevelIconFactory.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.icons;
18 |
19 | import java.awt.*;
20 | import java.net.URL;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 | import javax.swing.*;
24 | import javax.swing.plaf.metal.MetalLookAndFeel;
25 |
26 | /**
27 | */
28 | public class LevelIconFactory {
29 | private static final LevelIconFactory instance = new LevelIconFactory();
30 | private final Map iconMap = new HashMap<>();
31 |
32 | private LevelIconFactory() {
33 | // reuse ERROR icon for FATAL level
34 | String[] iconFileNames = new String[] {"Warn.gif", "Inform.gif", "Error.gif", "Error.gif"};
35 | String[] iconLabels = new String[] {"WARN", "INFO", "ERROR", "FATAL"};
36 |
37 | for (int i = 0; i < iconLabels.length; i++) {
38 | URL resourceURL = UIManager.getLookAndFeel().getClass().getResource("icons/" + iconFileNames[i]);
39 | if (resourceURL == null) {
40 | resourceURL = MetalLookAndFeel.class.getResource("icons/" + iconFileNames[i]);
41 | }
42 | if (resourceURL == null) {
43 | iconMap.put(iconLabels[i], ChainsawIcons.ICON_DEBUG);
44 | } else {
45 |
46 | final ImageIcon icon = new ImageIcon(resourceURL);
47 | double scalex = .5;
48 | double scaley = .5;
49 | final int newWidth = (int) (scalex * icon.getIconWidth());
50 | final int newHeight = (int) (scaley * icon.getIconHeight());
51 | Image iconImage = icon.getImage().getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH);
52 | iconMap.put(iconLabels[i], new ImageIcon(iconImage));
53 | }
54 | }
55 | // reuse DEBUG icon for TRACE level
56 | iconMap.put("TRACE", ChainsawIcons.ICON_DEBUG);
57 | iconMap.put("DEBUG", ChainsawIcons.ICON_DEBUG);
58 | }
59 |
60 | public static final LevelIconFactory getInstance() {
61 | return instance;
62 | }
63 |
64 | public Map getLevelToIconMap() {
65 | return iconMap;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/logevents/ChainsawLoggingEvent.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.logevents;
18 |
19 | import java.time.Instant;
20 | import java.util.HashMap;
21 | import java.util.Map;
22 | import java.util.Set;
23 |
24 | /**
25 | * The ChainsawLoggingEvent is a Chainsaw-specific type of logging event. This
26 | * ensures that logging events that we get from other sources all conform to
27 | * the same type of event, not just the Log4j1 style of logging event.
28 | *
29 | * ChainsawLoggingEvents are immutable, so use the ChainsawLoggingEventBuilder
30 | * class to construct one.
31 | */
32 | public class ChainsawLoggingEvent {
33 |
34 | public final Instant m_timestamp;
35 | public final Level m_level;
36 | public final String m_message;
37 | public final String m_threadName;
38 | public final String m_logger;
39 | public final LocationInfo m_locationInfo;
40 | public final String m_ndc;
41 | public final Map m_mdc;
42 | private Map m_properties;
43 |
44 | ChainsawLoggingEvent(ChainsawLoggingEventBuilder b) {
45 | m_timestamp = b.m_timestamp;
46 | m_level = b.m_level;
47 | m_message = b.m_message;
48 | m_threadName = b.m_threadName;
49 | m_logger = b.m_logger;
50 | m_locationInfo = b.m_locationInfo;
51 | m_ndc = b.m_ndc;
52 | m_mdc = b.m_mdc;
53 | m_properties = new HashMap<>();
54 | }
55 |
56 | public void setProperty(String name, String value) {
57 | m_properties.put(name, value);
58 | }
59 |
60 | public String removeProperty(String name) {
61 | return m_properties.remove(name);
62 | }
63 |
64 | public String getProperty(String name) {
65 | return m_properties.get(name);
66 | }
67 |
68 | public Set getPropertyKeySet() {
69 | return m_properties.keySet();
70 | }
71 |
72 | public Map getProperties() {
73 | return new HashMap<>(m_properties);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/logevents/Level.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.logevents;
18 |
19 | /**
20 | *
21 | */
22 | public enum Level {
23 | ALL,
24 | TRACE,
25 | DEBUG,
26 | INFO,
27 | WARN,
28 | ERROR,
29 | FATAL,
30 | OFF
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/logevents/LocationInfo.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.logevents;
18 |
19 | /**
20 | * Represents the location of a logging message.
21 | */
22 | public class LocationInfo {
23 | public final String fileName;
24 | public final String className;
25 | public final String methodName;
26 | public final int lineNumber;
27 |
28 | public LocationInfo(final String file, final String classname, final String method, final int line) {
29 | this.fileName = file;
30 | this.className = classname;
31 | this.methodName = method;
32 | this.lineNumber = line;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/osx/OSXIntegration.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.osx;
18 |
19 | import java.awt.Desktop;
20 | import org.apache.log4j.chainsaw.logui.LogUI;
21 |
22 | /**
23 | * This class leverages the 'Desktop' awt API in order to follow Mac-specific UI guidelines.
24 | *
25 | *
26 | * @author psmith
27 | * @see "http://developer.apple.com/documentation/Java/index.html"
28 | */
29 | public class OSXIntegration {
30 | public static final boolean IS_OSX = System.getProperty("os.name").startsWith("Mac OS X");
31 | private static final Desktop desktop = Desktop.getDesktop();
32 |
33 | public static void init(final LogUI logUI) {
34 | if (desktop.isSupported(Desktop.Action.APP_ABOUT)) {
35 | desktop.setAboutHandler(e -> logUI.showAboutBox());
36 | }
37 |
38 | if (desktop.isSupported(Desktop.Action.APP_PREFERENCES)) {
39 | desktop.setPreferencesHandler(e -> logUI.showApplicationPreferences());
40 | }
41 |
42 | if (desktop.isSupported(Desktop.Action.APP_QUIT_HANDLER)) {
43 | desktop.setQuitHandler((e, r) -> {
44 | if (logUI.exit()) {
45 | r.performQuit();
46 | } else {
47 | r.cancelQuit();
48 | }
49 | });
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/prefs/AbstractSettingsEvent.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.prefs;
18 |
19 | import java.io.File;
20 | import java.util.EventObject;
21 |
22 | /**
23 | * @author psmith
24 | */
25 | class AbstractSettingsEvent extends EventObject {
26 |
27 | private final File settingsLocation;
28 |
29 | /**
30 | * @param source
31 | */
32 | public AbstractSettingsEvent(Object source, File settingsLocation) {
33 | super(source);
34 | this.settingsLocation = settingsLocation;
35 | }
36 |
37 | public File getSettingsLocation() {
38 | return this.settingsLocation;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/log4j/chainsaw/prefs/LoadSettingsEvent.java:
--------------------------------------------------------------------------------
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 | package org.apache.log4j.chainsaw.prefs;
18 |
19 | import java.util.*;
20 |
21 | /**
22 | * @author Paul Smith <psmith@apache.org>
23 | */
24 | public class LoadSettingsEvent extends SettingsEvent {
25 |
26 | LoadSettingsEvent(Object source, Properties properties) {
27 | super(source);
28 | this.properties = properties;
29 | }
30 |
31 | public String getSetting(String key) {
32 | return properties.getProperty(key);
33 | }
34 |
35 | public boolean asBoolean(String key) {
36 | return Boolean.valueOf(getSetting(key));
37 | }
38 |
39 | public int asInt(String key) {
40 | String val = getSetting(key);
41 | try {
42 | return Integer.parseInt(val);
43 | } catch (NumberFormatException e) {
44 | e.printStackTrace();
45 | throw new RuntimeException("An error occurred retrieving the Integer value of the setting '" + key + "'");
46 | }
47 | }
48 |
49 | private final Properties properties;
50 |
51 | /**
52 | * Returns an unmodifiable Collection of values whose
53 | * setting key begins (String.startsWith()) the specified
54 | * string.
55 | *
56 | * @param string
57 | */
58 | public Collection getSettingsStartingWith(String string) {
59 | Collection c = new ArrayList();
60 |
61 | for (Map.Entry