📄 commonsquerylog.java
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- * $RCSFile$ $Revision: 1.4 $ $Date: 2006/02/01 00:17:24 $ * Copyright (c) 2004 Autonomy Corp. All Rights Reserved. */import java.io.*;import java.text.*;import java.util.*;import com.ultraseek.xpa.search.*;import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;/** * Logs queries via the Jakarta Commons Logging component. */public class CommonsQueryLog implements QueryLog{ /* Create a Log named "CommonsQueryLog". */ private static Log log = LogFactory.getLog(CommonsQueryLog.class); private static void logLine(StringBuffer sb, Query query, int numResults, String source, Date when) throws QueryNotSupportedException { // non-static because not thread safe SimpleDateFormat ultraQueryLogDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); // e.g. 1994/11/06 08:49:37 sb.append(ultraQueryLogDate.format(when)); sb.append("\t"); sb.append(numResults); sb.append("\t"); // no newlines or tabs, as they may be syntax in the log source = source.replace('\n', ' ').replace('\t', ' '); sb.append(source); sb.append("\t"); String qt = QueryUtil.unparse(query); // no newlines or tabs, as they may be syntax in the log qt = qt.replace('\n', ' ').replace('\t', ' '); sb.append(qt); } /** * {@inheritDoc} * Logs a query to a Jakarta Commons Logging Log in the style of the * Ultraseek query log file. * <p> * All messages are logged at the info level. */ public void logQuery(Query query, SearchResultList result, String source, Date when) throws QueryNotSupportedException, IOException { int numResults = result.getResultCount(); StringBuffer sb = new StringBuffer(128); logLine(sb, query, numResults, source, when); String entry = sb.toString(); log.info(entry); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -