storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptgo...@apache.org
Subject [02/24] git commit: logviewer tries to determine log directory via logback configuration, falls back to storm.home/logs
Date Tue, 19 Nov 2013 15:26:39 GMT
logviewer tries to determine log directory via logback configuration, falls back to storm.home/logs


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/30c5d668
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/30c5d668
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/30c5d668

Branch: refs/heads/master
Commit: 30c5d668da3e3bcea931d7e635043689c5c45984
Parents: 1e3d266
Author: Homer Strong <homer.strong@gmail.com>
Authored: Thu Oct 10 11:55:37 2013 -0700
Committer: Homer Strong <homer.strong@gmail.com>
Committed: Thu Oct 10 11:55:37 2013 -0700

----------------------------------------------------------------------
 .../src/clj/backtype/storm/daemon/logviewer.clj    | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/30c5d668/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/logviewer.clj b/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
index 3cc8b39..9bb56b1 100644
--- a/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
@@ -3,11 +3,15 @@
   (:use [hiccup core page-helpers])
   (:use [backtype.storm config util log])
   (:use [ring.adapter.jetty :only [run-jetty]])
+  (:import [org.slf4j LoggerFactory])
+  (:import [ch.qos.logback.classic Logger])
   (:import [org.apache.commons.logging LogFactory])
   (:import [org.apache.commons.logging.impl Log4JLogger])
+  (:import [ch.qos.logback.core FileAppender])
   (:import [org.apache.log4j Level])
   (:require [compojure.route :as route]
-            [compojure.handler :as handler])
+            [compojure.handler :as handler]
+            [clojure.string :as string])
   (:gen-class))
 
 (defn tail-file [path tail]
@@ -25,8 +29,17 @@
       (.toString output))
     ))
 
+(defn log-root-dir
+  []
+  (let [appender (first (iterator-seq (.iteratorForAppenders (LoggerFactory/getLogger Logger/ROOT_LOGGER_NAME))))]
+    (if (and appender (instance? FileAppender appender))
+      (string/join
+       "/" (butlast
+            (string/split (.getFile appender) #"/")))
+      (str (System/getProperty "storm.home") "/logs/"))))
+
 (defn log-page [file tail grep]
-  (let [path (str (System/getProperty "storm.home") "/logs/" file)
+  (let [path (str (log-root-dir) "/" file)
         tail (if tail
                (min 10485760 (Integer/parseInt tail))
                10240)


Mime
View raw message