cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [1/2] git commit: updated refs/heads/master to cab57b2
Date Fri, 28 Aug 2015 11:57:27 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master a7418751c -> cab57b248


Putting CglibThrowableRenderer.java back after it was removed in 83fd8f6

Also removing the entry 'log/' from .gitignore since that was the
culprit for the removal of the file.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4c1a5f76
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4c1a5f76
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4c1a5f76

Branch: refs/heads/master
Commit: 4c1a5f76570115e0dcc41c74c07c7d99546a8029
Parents: a741875
Author: Miguel Ferreira <miguelferreira@me.com>
Authored: Fri Aug 28 11:18:44 2015 +0200
Committer: Miguel Ferreira <miguelferreira@me.com>
Committed: Fri Aug 28 11:18:44 2015 +0200

----------------------------------------------------------------------
 .gitignore                                      |  1 -
 .../cloud/utils/log/CglibThrowableRenderer.java | 84 ++++++++++++++++++++
 2 files changed, 84 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c1a5f76/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index b9dafcf..58eafaf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,7 +85,6 @@ configure-stamp
 *_flymake.js
 engine/storage/integration-test/test-output
 tools/apidoc/log/
-log/
 plugins/network-elements/juniper-contrail/logs/
 scripts/vm/hypervisor/xenserver/vhd-util
 *.orig

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c1a5f76/utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java b/utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java
new file mode 100644
index 0000000..b102dc4
--- /dev/null
+++ b/utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java
@@ -0,0 +1,84 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.utils.log;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+import org.apache.log4j.spi.ThrowableRenderer;
+
+/**
+ * This renderer removes all the Cglib generated methods from the call
+ *
+ * Unfortunately, I had to copy out the EnhancedThrowableRenderer from
+ * the apach libraries because EnhancedThrowableRenderer is a final class.
+ * simply override doRender. Not sure what the developers are thinking there
+ * making it final.
+ *
+ * <throwableRenderer class="com.cloud.utils.log.CglibThrowableRenderer"/>
+ * into log4j.xml.
+ *
+ */
+public class CglibThrowableRenderer implements ThrowableRenderer {
+    /**
+     * Construct new instance.
+     */
+    public CglibThrowableRenderer() {
+        super();
+    }
+
+    @Override
+    public String[] doRender(final Throwable th) {
+        try {
+            ArrayList<String> lines = new ArrayList<String>();
+            Throwable throwable = th;
+            lines.add(throwable.toString());
+            int start = 0;
+            do {
+                StackTraceElement[] elements = throwable.getStackTrace();
+                for (int i = 0; i < elements.length - start; i++) {
+                    StackTraceElement element = elements[i];
+                    String filename = element.getFileName();
+                    String method = element.getMethodName();
+                    if ((filename != null && filename.equals("<generated>"))
|| (method != null && method.equals("invokeSuper"))) {
+                        continue;
+                    }
+                    lines.add("\tat " + element.toString());
+                }
+                if (start != 0) {
+                    lines.add("\t... " + start + " more");
+                }
+                throwable = throwable.getCause();
+                if (throwable != null) {
+                    lines.add("Caused by: " + throwable.toString());
+                    start = elements.length - 1;
+                }
+            } while (throwable != null);
+            return lines.toArray(new String[lines.size()]);
+        } catch (Exception ex) {
+            PrintWriter pw = new PrintWriter(System.err);
+            ex.printStackTrace(pw);
+            pw = new PrintWriter(System.out);
+            ex.printStackTrace(pw);
+            ex.printStackTrace();
+            return null;
+        }
+    }
+}


Mime
View raw message