- From: Mercurial notifier <nobody@w3.org>
- Date: Tue, 23 Nov 2010 18:03:59 +0000
- To: Unicorn Updates <www-validator-cvs@w3.org>
changeset: 1566:5923e9bd6b48 user: Thomas Gambet <tgambet@w3.org> date: Thu Nov 18 17:12:24 2010 -0500 files: src/org/w3c/unicorn/RequestThread.java src/org/w3c/unicorn/action/ObserveAction.java src/org/w3c/unicorn/exceptions/UnicornException.java description: + added logging of critical errors with parameters diff -r 64034bcbdba5 -r 5923e9bd6b48 src/org/w3c/unicorn/RequestThread.java --- a/src/org/w3c/unicorn/RequestThread.java Thu Nov 18 14:25:29 2010 -0500 +++ b/src/org/w3c/unicorn/RequestThread.java Thu Nov 18 17:12:24 2010 -0500 @@ -21,7 +21,8 @@ /** * Used for complex logging purpose */ - private static final Log logger = LogFactory.getLog(RequestThread.class);; + private static final Log logger = LogFactory.getLog(RequestThread.class); + private static final Log criticalLogger = LogFactory.getLog("CriticalError"); private Response aResponse; @@ -67,6 +68,7 @@ aResponse.setObserverId(obsID); } catch (final UnicornException e) { messages.add(e.getUnicornMessage()); + criticalLogger.error("Observer request failed: \n\t Request: " + aRequest.getInputMethod().toString() + " - " + this.aRequest.toString() + "\n " + e.getMessage()); } catch (final Exception e) { messages.add(new Message(e)); logger.error(e.getMessage(), e); diff -r 64034bcbdba5 -r 5923e9bd6b48 src/org/w3c/unicorn/action/ObserveAction.java --- a/src/org/w3c/unicorn/action/ObserveAction.java Thu Nov 18 14:25:29 2010 -0500 +++ b/src/org/w3c/unicorn/action/ObserveAction.java Thu Nov 18 17:12:24 2010 -0500 @@ -49,6 +49,7 @@ private static final long serialVersionUID = -1375355420965607571L; private static Log logger = LogFactory.getLog(ObserveAction.class); + private static Log criticalLogger = LogFactory.getLog("CriticalError"); private static DiskFileItemFactory factory; @@ -317,7 +318,18 @@ aOutputModule.produceError(mapOfStringObject, resp.getWriter()); } } catch (final Exception aException) { - logger.error("Exception : " + aException.getMessage(), aException); + StringBuilder log = new StringBuilder(); + for (String key : reqParams.keySet()) { + log.append(key + " -> "); + if (reqParams.get(key) instanceof String[]) { + String[] params = (String[]) reqParams.get(key); + for (String param : params) + log.append(param + "\n"); + } else { + log.append(reqParams.get(key) + "\n"); + } + } + criticalLogger.error("Critical: \n" + log, aException); messages.add(new Message(aException)); aOutputModule.produceError(mapOfStringObject, resp.getWriter()); } finally { diff -r 64034bcbdba5 -r 5923e9bd6b48 src/org/w3c/unicorn/exceptions/UnicornException.java --- a/src/org/w3c/unicorn/exceptions/UnicornException.java Thu Nov 18 14:25:29 2010 -0500 +++ b/src/org/w3c/unicorn/exceptions/UnicornException.java Thu Nov 18 17:12:24 2010 -0500 @@ -38,5 +38,15 @@ public void setUnicornMessage(Message message) { this.message = message; } + + @Override + public String getMessage() { + if (super.getMessage() == null || super.getMessage().equals("")) + return message.getContent(); + else + return super.getMessage(); + } + + }
Received on Tuesday, 23 November 2010 18:04:01 UTC