Revision: 8436
http://languagetool.svn.sourceforge.net/languagetool/?rev=8436&view=rev
Author: dnaber
Date: 2012-11-22 22:30:48 +0000 (Thu, 22 Nov 2012)
Log Message:
-----------
http/https server: more compact logging (one line per check instead of three);
log in second resolution
Modified Paths:
--------------
trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
Modified:
trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
===================================================================
---
trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
2012-11-22 16:50:27 UTC (rev 8435)
+++
trunk/JLanguageTool/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java
2012-11-22 22:30:48 UTC (rev 8436)
@@ -63,7 +63,6 @@
@Override
public void handle(HttpExchange httpExchange) throws IOException {
- final long timeStart = System.currentTimeMillis();
String text = null;
try {
final URI requestedUri = httpExchange.getRequestURI();
@@ -96,7 +95,6 @@
} finally {
httpExchange.close();
}
- print("Check done in " + (System.currentTimeMillis() - timeStart) + "ms");
}
private void sendError(HttpExchange httpExchange, int returnCode, String
response) throws IOException {
@@ -154,6 +152,7 @@
}
private void checkText(String text, HttpExchange httpExchange, Map<String,
String> parameters) throws Exception {
+ final long timeStart = System.currentTimeMillis();
if (text.length() > maxTextLength) {
throw new IllegalArgumentException("Text is " + text.length() + "
characters long, exceeding maximum length of " + maxTextLength);
}
@@ -195,7 +194,6 @@
final String sourceText = parameters.get("srctext");
if (sourceText == null) {
final JLanguageTool lt = getLanguageToolInstance(lang, motherTongue);
- print("Checking " + text.length() + " characters of text, language " +
langParam);
matches = lt.check(text);
} else {
if (motherTongueParam == null) {
@@ -210,11 +208,16 @@
matches = Tools.checkBitext(sourceText, text, sourceLt, targetLt,
bRules);
}
httpExchange.getResponseHeaders().set("Content-Type", CONTENT_TYPE_VALUE);
- //httpExchange.getResponseHeaders().set("Access-Control-Allow-Origin",
"*");
final String response = StringTools.ruleMatchesToXML(matches, text,
CONTEXT_SIZE, StringTools.XmlPrintMode.NORMAL_XML, lang,
motherTongue);
httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK,
response.getBytes(ENCODING).length);
httpExchange.getResponseBody().write(response.getBytes(ENCODING));
+ String languageMessage = lang.getShortNameWithVariant();
+ if (motherTongue != null) {
+ languageMessage += " (mother tongue: " +
motherTongue.getShortNameWithVariant() + ")";
+ }
+ print("Check done: " + text.length() + " characters, language " +
languageMessage + ", "
+ + (System.currentTimeMillis() - timeStart) + "ms");
}
private Map<String, String> parseQuery(String query) throws
UnsupportedEncodingException {
@@ -242,7 +245,7 @@
}
private static void print(String s) {
- final SimpleDateFormat dateFormat = new SimpleDateFormat();
+ final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");
final String now = dateFormat.format(new Date());
System.out.println(now + " " + s);
}
@@ -258,7 +261,6 @@
* @throws Exception when JLanguageTool creation failed
*/
private JLanguageTool getLanguageToolInstance(Language lang, Language
motherTongue) throws Exception {
- print("Creating JLanguageTool instance for language " + lang + ((null !=
motherTongue) ? (" and mother tongue " + motherTongue) : ""));
final JLanguageTool newLanguageTool = new JLanguageTool(lang,
motherTongue);
newLanguageTool.activateDefaultPatternRules();
newLanguageTool.activateDefaultFalseFriendRules();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits