Skip to content

Commit

Permalink
externalizing logging, and added dependency on my clj-utils git project
Browse files Browse the repository at this point in the history
  • Loading branch information
amitrathore committed Jul 14, 2009
1 parent 5ee7f87 commit 04630fd
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "lib/clojure/clj-record"]
path = lib/clojure/clj-record
url = git://github.com/duelinmarkers/clj-record.git
[submodule "lib/clojure/clj-utils"]
path = lib/clojure/clj-utils
url = git://github.com/amitrathore/clj-utils.git
2 changes: 1 addition & 1 deletion fujure.sh
Expand Up @@ -30,7 +30,7 @@ echo "SWARMIJI_HOME is ${SWARMIJI_HOME}"
echo "SWARMIJI_ENV is ${SWARMIJI_ENV}"

swarmiji_jars="${SWARMIJI_HOME}/lib/java"
swarmiji_clj="${SWARMIJI_HOME}/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/src/"
swarmiji_clj="${SWARMIJI_HOME}/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/src/:${SWARMIJI_HOME}/lib/clojure/clj-utils/src/"

clj_cp="."
[ -f /etc/clojure.conf ] && . /etc/clojure.conf
Expand Down
1 change: 1 addition & 0 deletions lib/clojure/clj-utils
Submodule clj-utils added at e57ad3
3 changes: 2 additions & 1 deletion src/org/runa/swarmiji/client/client_core.clj
Expand Up @@ -2,11 +2,12 @@

(use 'org.runa.swarmiji.mpi.sevak-proxy)
(use 'org.runa.swarmiji.mpi.transport)
(use 'org.runa.swarmiji.utils.logger)
(use 'org.runa.swarmiji.config.system-config)
(use 'org.runa.swarmiji.utils.general-utils)
(require '(org.danlarkin [json :as json]))
(import '(java.io StringWriter))
(use 'org.rathore.amit.utils.config)
(use 'org.rathore.amit.utils.logger)

(def WORK-REPORT "WORK_REPORT")

Expand Down
9 changes: 6 additions & 3 deletions src/org/runa/swarmiji/config/system_config.clj
Expand Up @@ -18,8 +18,6 @@
(defn swarmiji-mysql-config []
(environment-specific-config-from swarmiji-mysql-configs))

(def logfile (str ((operation-config) :logsdir) "/" *swarmiji-env* "_" (process-pid) ".log"))

(defn swarmiji-user []
((operation-config) :swarmiji-username))

Expand Down Expand Up @@ -48,4 +46,9 @@
((operation-config) :diagnostics-mode))

(defn log-to-console? []
((operation-config) :log-to-console))
((operation-config) :log-to-console))

(defn config-for-rathore-utils [process-type-id]
{:log-to-console (log-to-console?)
:logs-dir ((operation-config) :logsdir)
:log-filename-prefix (str process-type-id "_" *swarmiji-env*)})
5 changes: 3 additions & 2 deletions src/org/runa/swarmiji/http/web_server_2.clj
Expand Up @@ -6,12 +6,12 @@
(import '(com.sun.grizzly.util.buf ByteChunk))
(import '(java.net HttpURLConnection))
(use 'org.runa.swarmiji.utils.general-utils)
(use 'org.runa.swarmiji.utils.logger)
(use 'org.runa.swarmiji.utils.exception-utils)
(require '(org.danlarkin [json :as json]))
(use 'org.runa.swarmiji.config.system-config)
(use 'org.runa.swarmiji.sevak.sevak-core)
(use 'org.runa.swarmiji.http.helper)
(use 'org.rathore.amit.utils.config)
(use 'org.rathore.amit.utils.logger)

(defn singularize-values [a-map]
(if (empty? a-map)
Expand Down Expand Up @@ -96,5 +96,6 @@
(let [gws (GrizzlyWebServer. port)]
(.addGrizzlyAdapter gws (grizzly-adapter-for handler-functions-as-route-map))
(log-message "web-server-2: Using config:" (operation-config))
(log-message "web-server-2: RabbitMQ channel:" (queue-sevak-q-name))
(log-message "Started swarmiji-http-gateway on port" port)
(.start gws)))
16 changes: 9 additions & 7 deletions src/org/runa/swarmiji/monitor/recorder.clj
@@ -1,7 +1,8 @@
(ns org.runa.swarmiji.monitor.recorder
(:use [org.runa.swarmiji.mpi.transport])
(:use [org.runa.swarmiji.config.system-config])
(:use [org.runa.swarmiji.utils.logger])
(:use [org.rathore.amit.utils.config])
(:use [org.rathore.amit.utils.logger])
(:use [org.runa.swarmiji.monitor.control_message :as control-message])
(:import (java.sql Date Time)))

Expand All @@ -15,10 +16,11 @@
(control-message/insert with-timestamps)))

(defn start []
(let [client (new-queue-client)
q-name (queue-diagnostics-q-name)
handler (queue-message-handler-for-function persist-message)]
(log-message "Swarmiji: Starting Control-Message-Recorder...")
(log-message "Listening on:" q-name)
(.subscribe client q-name handler)))
(binding [*rathore-utils-config* (config-for-rathore-utils "recorder")]
(let [client (new-queue-client)
q-name (queue-diagnostics-q-name)
handler (queue-message-handler-for-function persist-message)]
(log-message "Swarmiji: Starting Control-Message-Recorder...")
(log-message "Listening on:" q-name)
(.subscribe client q-name handler))))

3 changes: 1 addition & 2 deletions src/org/runa/swarmiji/mpi/transport.clj
Expand Up @@ -3,8 +3,7 @@
(use 'org.runa.swarmiji.config.system-config)
(require '(org.danlarkin [json :as json]))
(import '(net.ser1.stomp Client Listener))
(use 'org.runa.swarmiji.utils.exception-utils)
(use 'org.runa.swarmiji.utils.logger)
(use 'org.rathore.amit.utils.logger)

(defn new-queue-client []
(Client. (queue-host) (queue-port), (queue-username) (queue-password)))
Expand Down
9 changes: 5 additions & 4 deletions src/org/runa/swarmiji/sevak/sevak_core.clj
@@ -1,13 +1,13 @@
(ns org.runa.swarmiji.sevak.sevak-core)

(use 'org.runa.swarmiji.mpi.transport)
(use 'org.runa.swarmiji.utils.exception-utils)
(import '(net.ser1.stomp Client Listener))
(require '(org.danlarkin [json :as json]))
(use 'org.runa.swarmiji.client.client-core)
(use 'org.runa.swarmiji.config.system-config)
(use 'org.runa.swarmiji.utils.general-utils)
(use 'org.runa.swarmiji.utils.logger)
(use 'org.rathore.amit.utils.config)
(use 'org.rathore.amit.utils.logger)

(def sevaks (ref {}))
(def swarmiji-bindings (ref {}))
Expand Down Expand Up @@ -54,7 +54,8 @@
(defn sevak-request-handling-listener []
(proxy [Listener] []
(message [headerMap messageBody]
(try
(with-swarmiji-bindings
(try
(let [req-json (json/decode-from-str messageBody)
_ (log-message "got request" req-json)
service-name (req-json :sevak-service-name) service-args (req-json :sevak-service-args) return-q (req-json :return-queue-name)
Expand All @@ -64,7 +65,7 @@
(throw (Exception. (str "No handler found for: " service-name))))
(send sevak-agent async-sevak-handler service-name service-args return-q))
(catch Exception e
(log-exception e))))))
(log-exception e)))))))

(defn start-sevak-listener []
(let [client (new-queue-client)
Expand Down
17 changes: 0 additions & 17 deletions src/org/runa/swarmiji/utils/exception_utils.clj

This file was deleted.

20 changes: 0 additions & 20 deletions src/org/runa/swarmiji/utils/logger.clj

This file was deleted.

0 comments on commit 04630fd

Please sign in to comment.