Skip to content

Commit

Permalink
better service logging
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Nov 26, 2024
1 parent bdca5e8 commit be9ee3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
17 changes: 12 additions & 5 deletions spa/src/webly/spa/service.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@
(defn start-cljs-service [resolver {:keys [name config start-fn]}]
(let [r-p (p/deferred)
start-p (resolver start-fn)]
(warn "starting cljs-service name: " name "start-fn: " start-fn)
(info "starting cljs-service name: " name "start-fn: " start-fn)
(-> start-p
(p/then (fn [start]
(let [r (start config)]
(if (p/promise? r)
(-> r
(p/then (fn [_] (p/resolve! r-p nil)))
(p/then (fn [_]
(info "clj-service name: " name " successfully started!")
(p/resolve! r-p nil)))
(p/catch (fn [err]
(error "error in starting service: " start-fn " err: " err)))
r)
(p/resolve! r-p nil))))))
(error "clj-service name: " name "cannot be started. start-fn: " start-fn " error: " err)
(p/reject! r-p nil))))
(do
(info "clj-service name: " name " successfully started!")
(p/resolve! r-p nil))))))
(p/catch (fn [err]
(error "could not resolve service: " start-fn " error: " err)
(p/reject! r-p nil))))
r-p))

(defn start-cljs-services [services]
Expand Down
10 changes: 5 additions & 5 deletions webly/src/webly/module/build.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
(let [loadable (get @lazy-ns-loadable-a ns-name)
rp (p/deferred)
on-error (fn [err]
(println "could not load ns: " ns-name " ERROR: " err)
;(println "could not load ns: " ns-name " ERROR: " err)
(p/reject! rp err))
on-success (fn [vars]
(println "ns [" ns-name "] loaded successfully!")
;(println "ns [" ns-name "] loaded successfully!")
(p/resolve! rp vars))]
; lazy/load does return a google deferred, so we cannot use promises here.
(try
Expand Down Expand Up @@ -106,7 +106,7 @@
(let [rp2 (load-namespace-raw ns-name)]
(-> rp2
(p/then (fn [vars]
(println "load-namespace vars successfully received!")
;(println "load-namespace vars successfully received!")
(p/resolve! rp (assemble-simple-ns ns-name vars))))))
(do (println "cannot load-namespace [" (pr-str ns-name) "] - not a simple-namespace!")
(p/reject! rp (str "cannot load-namespace: "
Expand All @@ -122,8 +122,8 @@
(-> ns-rp
(p/then (fn [ns-map]
(if-let [fun (get ns-map fn-symbol)]
(do (println "resolved successfully: " fq-symbol)
(p/resolve! rp fun))
(do ;(println "resolved successfully: " fq-symbol)
(p/resolve! rp fun))
(do (println "could not resolve: " fq-symbol)
(p/reject! rp (str "namespace does not contain function: " fn-symbol))))))
(p/catch (fn [err]
Expand Down

0 comments on commit be9ee3b

Please sign in to comment.