/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software
* License version 1.1, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*/
package org.apache.log4j.lf5.viewer;
import org.apache.log4j.lf5.LogLevel;
import org.apache.log4j.lf5.LogRecord;
import org.apache.log4j.lf5.LogRecordFilter;
import org.apache.log4j.lf5.util.DateFormatManager;
import org.apache.log4j.lf5.util.LogFileParser;
import org.apache.log4j.lf5.util.StreamUtils;
import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerTree;
import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryPath;
import org.apache.log4j.lf5.viewer.configure.ConfigurationManager;
import org.apache.log4j.lf5.viewer.configure.MRUFileManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.util.List;
/**
* LogBrokerMonitor
*.
* @author Michael J. Sikorsky
* @author Robert Shaw
* @author Brad Marlborough
* @author Richard Wan
* @author Brent Sprecher
* @author Richard Hurst
*/
// Contributed by ThoughtWorks Inc.
public class LogBrokerMonitor {
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
public static final String DETAILED_VIEW = "Detailed";
// public static final String STANDARD_VIEW = "Standard";
// public static final String COMPACT_VIEW = "Compact";
//--------------------------------------------------------------------------
// Protected Variables:
//--------------------------------------------------------------------------
protected JFrame _logMonitorFrame;
protected int _logMonitorFrameWidth = 550;
protected int _logMonitorFrameHeight = 500;
protected LogTable _table;
protected CategoryExplorerTree _categoryExplorerTree;
protected String _searchText;
protected String _NDCTextFilter = "";
protected LogLevel _leastSevereDisplayedLogLevel = LogLevel.DEBUG;
protected JScrollPane _logTableScrollPane;
protected JLabel _statusLabel;
protected Object _lock = new Object();
protected JComboBox _fontSizeCombo;
protected int _fontSize = 10;
protected String _fontName = "Dialog";
protected String _currentView = DETAILED_VIEW;
protected boolean _loadSystemFonts = false;
protected boolean _trackTableScrollPane = true;
protected Dimension _lastTableViewportSize;
protected boolean _callSystemExitOnClose = false;
protected List _displayedLogBrokerProperties = new Vector();
protected Map _logLevelMenuItems = new HashMap();
protected Map _logTableColumnMenuItems = new HashMap();
protected List _levels = null;
protected List _columns = null;
protected boolean _isDisposed = false;
protected ConfigurationManager _configurationManager = null;
protected MRUFileManager _mruFileManager = null;
protected File _fileLocation = null;
//--------------------------------------------------------------------------
// Private Variables:
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Constructors:
//--------------------------------------------------------------------------
/**
* Construct a LogBrokerMonitor.
*/
public LogBrokerMonitor(List logLevels) {
_levels = logLevels;
_columns = LogTableColumn.getLogTableColumns();
// This allows us to use the LogBroker in command line tools and
// have the option for it to shutdown.
String callSystemExitOnClose =
System.getProperty("monitor.exit");
if (callSystemExitOnClose == null) {
callSystemExitOnClose = "false";
}
callSystemExitOnClose = callSystemExitOnClose.trim().toLowerCase();
if (callSystemExitOnClose.equals("true")) {
_callSystemExitOnClose = true;
}
initComponents();
_logMonitorFrame.addWindowListener(
new LogBrokerMonitorWindowAdaptor(this));
}
//--------------------------------------------------------------------------
// Public Methods:
//--------------------------------------------------------------------------
/**
* Show the frame for the LogBrokerMonitor. Dispatched to the
* swing thread.
*/
public void show(final int delay) {
if (_logMonitorFrame.isVisible()) {
return;
}
// This request is very low priority, let other threads execute first.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Thread.yield();
pause(delay);
_logMonitorFrame.setVisible(true);
}
});
}
public void show() {
show(0);
}
/**
* Dispose of the frame for the LogBrokerMonitor.
*/
public void dispose() {
_logMonitorFrame.dispose();
_isDisposed = true;
if (_callSystemExitOnClose == true) {
System.exit(0);
}
}
/**
* Hide the frame for the LogBrokerMonitor.
*/
public void hide() {
_logMonitorFrame.setVisible(false);
}
/**
* Get the DateFormatManager for formatting dates.
*/
public DateFormatManager getDateFormatManager() {
return _table.getDateFormatManager();
}
/**
* Set the date format manager for formatting dates.
*/
public void setDateFormatManager(DateFormatManager dfm) {
_table.setDateFormatManager(dfm);
}
/**
* Get the value of whether or not System.exit() will be called
* when the LogBrokerMonitor is closed.
*/
public boolean getCallSystemExitOnClose() {
return _callSystemExitOnClose;
}
/**
* Set the value of whether or not System.exit() will be called
* when the LogBrokerMonitor is closed.
*/
public void setCallSystemExitOnClose(boolean callSystemExitOnClose) {
_callSystemExitOnClose = callSystemExitOnClose;
}
/**
* Add a log record message to be displayed in the LogTable.
* This method is thread-safe as it posts requests to the SwingThread
* rather than processing directly.
*/
public void addMessage(final LogRecord lr) {
if (_isDisposed == true) {
// If the frame has been disposed of, do not log any more
// messages.
return;
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_categoryExplorerTree.getExplorerModel().addLogRecord(lr);
_table.getFilteredLogTableModel().addLogRecord(lr); // update table
updateStatusLabel(); // show updated counts
}
});
}
public void setMaxNumberOfLogRecords(int maxNumberOfLogRecords) {
_table.getFilteredLogTableModel().setMaxNumberOfLogRecords(maxNumberOfLogRecords);
}
public JFrame getBaseFrame() {
return _logMonitorFrame;
}
public void setTitle(String title) {
_logMonitorFrame.setTitle(title + " - LogFactor5");
}
public void setFrameSize(int width, int height) {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
if (0 < width && width < screen.width) {
_logMonitorFrameWidth = width;
}
if (0 < height && height < screen.height) {
_logMonitorFrameHeight = height;
}
updateFrameSize();
}
public void setFontSize(int fontSize) {
changeFontSizeCombo(_fontSizeCombo, fontSize);
// setFontSizeSilently(actualFontSize); - changeFontSizeCombo fires event
// refreshDetailTextArea();
}
public void addDisplayedProperty(Object messageLine) {
_displayedLogBrokerProperties.add(messageLine);
}
public Map getLogLevelMenuItems() {
return _logLevelMenuItems;
}
public Map getLogTableColumnMenuItems() {
return _logTableColumnMenuItems;
}
public JCheckBoxMenuItem getT
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台、文件、GUI组件、甚至是套接口服务器、NT的事件记录器、UNIX Syslog守护进程等;我们也可以控制每一条日志的输出格式;通过定义每一条日志信息的级别,我们能够更加细致地控制日志的生成过程。最令人感兴趣的就是,这些可以通过一个配置文件来灵活地进行配置,而不需要修改应用的代码。
资源推荐
资源详情
资源评论
















收起资源包目录





































































































共 796 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论

- 非非非常大的草履虫2013-12-14可以用,谢谢LZ~~
- qq_299635612015-07-20可以用的,谢谢
- huangdeji2014-03-28可以用,多谢分享。

opsu
- 粉丝: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 企业人力资源管理的思考的论文-计算机理论论文(1).docx
- 2020年长春电大计算机科学技术毕业论文开题报告(1).doc
- 本科毕业设计论文--基于plc行车控制设计(1).doc
- 智能电网电力通信中的分组传送网技术应用探讨(1).docx
- 基于web的教师教学辅助系统的设计与实现毕业论文(1).pdf
- 新形势下中国通信制造企业可持续发展战略的探讨.pdf
- 浅析电子商务中的物流瓶颈与对策论文(1).docx
- 信息化档案在电网运行管理中的应用(1).docx
- 基于mssqlserver的银行信贷管理系统的设计与实现-计算机应用专业大学硕士毕业论文(1).doc
- 软件工程毕业设计-基于python的博客设计与开发(1).doc
- 管理系统中计算机应用题目及答案(1).doc
- 信息化升级实施计划(1).pptx
- 互联网+时代高校教育管理新模式初探(1).docx
- CAD工程制图建筑识图与建筑房屋施工图认知(1).ppt
- 高职计算机教学中互动式教学的应用(1).docx
- 非关系型数据库在天文领域中的应用(1).ppt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
