loglayout.java

来自「用java开发的一些实用的短信通信模块其中包含MD5加密、http发送等信息」· Java 代码 · 共 30 行

JAVA
30
字号
package lib.commons.logging;

import java.io.PrintWriter;
import java.io.StringWriter;

import lib.commons.Utils;

import org.apache.commons.configuration.Configuration;

public class LogLayout {
	public LogLayout(Configuration configuration) {}

	public String formatLogInfo(LogInfo logInfo) {
		if (null == logInfo)
			return Utils.EMPTY_STRING;
		if (!logInfo.isPrintStackTrace())
			return null == logInfo.getLogMessage() ? Utils.EMPTY_STRING
					: logInfo.getLogMessage().toString();
		StringWriter stringWriter = new StringWriter();
		PrintWriter writer = new PrintWriter(stringWriter);
		writer.print(null == logInfo.getLogMessage() ? Utils.EMPTY_STRING
				: logInfo.getLogMessage().toString());
		if (null != logInfo.getLogThrowable()) {
			writer.println();
			logInfo.getLogThrowable().printStackTrace(writer);
		}
		return stringWriter.toString();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?