brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #647: better logging of REST exceptions
Date Fri, 28 Apr 2017 10:54:34 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/647#discussion_r113902113
  
    --- Diff: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/DefaultExceptionMapper.java
---
    @@ -120,6 +121,32 @@ public Response toResponse(Throwable throwable1) {
             return rb.build().asResponse(Status.INTERNAL_SERVER_ERROR, MediaType.APPLICATION_JSON_TYPE);
         }
         
    +    /** Logs full details at trace, unless it is the first time we've seen this in which
case it is debug */
    +    @Beta
    +    public static void logExceptionDetailsForDebugging(Throwable t) {
    +        if (LOG.isDebugEnabled()) {
    +            if (firstEncounter(t)) {
    +                // include debug trace for everything the first time we get one
    +                LOG.debug("Full details of "+Entitlements.getEntitlementContext()+" "+t+"
(logging debug on first encounter; subsequent instances will be logged trace)", t);
    +            } else if (LOG.isTraceEnabled()) {
    +                LOG.trace("Full details of "+Entitlements.getEntitlementContext()+" "+t,
t);
    +            }
    +        }
    +    }
    +        
    +    private static boolean firstEncounter(Throwable t) {
    +        Set<Object> record = MutableSet.of();
    +        while (true) {
    --- End diff --
    
    Interesting, that's a nice guideline, now that you mention it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message