📄 loglayout.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.util;
import java.sql.Timestamp;
import java.awt.Toolkit;
import org.apache.log4j.*;
import org.apache.log4j.spi.*;
/**
* Log4J Formatter
*
* @author Jorg Janke
* @version $Id: LogLayout.java,v 1.2 2003/03/20 06:51:23 jjanke Exp $
*/
public class LogLayout extends Layout
{
/**
* Constructor
*/
public LogLayout()
{
} // LogLayout
/**
* Create layout format.
* @param event log event
* @return formatted string
*/
public String format (LoggingEvent event)
{
StringBuffer sb = new StringBuffer();
Timestamp ts = new Timestamp(event.timeStamp);
String tstr = ts.toString() + "00";
//
int prio = event.getLevel().toInt(); // Priority
if (prio == Priority.FATAL_INT || prio == Priority.ERROR_INT)
{
// 12:12:12.123
sb.append("===========> ");
//
Toolkit.getDefaultToolkit().beep();
//
if (event.getMessage() != null)
Log.writeDBLog(event.getLoggerName(), event.getMessage().toString());
}
else
{
sb.append(tstr.substring(11, 23));
int level = 1;
// if (prio == Priority.INFO_INT);
if (prio == Priority.DEBUG_INT)
level = 2;
// + " [" + level + "]"
sb.append(" ".substring(0, level << 1));
}
String className = event.getLoggerName();
int pos = className.lastIndexOf('.');
if (pos != -1)
className = className.substring(pos+1);
sb.append(className)
.append(": ")
.append(event.getMessage());
// Throwable
ThrowableInformation ti = event.getThrowableInformation();
if (ti != null)
{
}
sb.append(Env.NL);
return sb.toString();
} // format
/**
If the layout handles the throwable object contained within
{@link LoggingEvent}, then the layout should return
<code>false</code>. Otherwise, if the layout ignores throwable
object, then the layout should return <code>true</code>.
* @return false
**/
public boolean ignoresThrowable()
{
return true;
}
/**
Does not do anything as options become effective
*/
public void activateOptions()
{
// nothing to do.
}
} // LogLayout
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -