add better websocker related logging
This commit is contained in:
parent
7ccd356e8c
commit
7fc8cd9dcd
2 changed files with 6 additions and 5 deletions
|
|
@ -6,7 +6,6 @@
|
|||
[hato.websocket :as ws]
|
||||
[cheshire.core :as json]
|
||||
[clojure.string :as str]
|
||||
[clojure.pprint :refer [pprint]]
|
||||
[micro-blog.config :refer [config]])
|
||||
(:import
|
||||
[java.time Instant OffsetDateTime ZoneOffset]
|
||||
|
|
@ -55,11 +54,13 @@
|
|||
|
||||
(def socket (atom nil))
|
||||
(defn connect []
|
||||
(tel/log! :info "Opening websocket connection to nostr relay")
|
||||
(reset! socket @(ws/websocket (@config :nostr-relay)
|
||||
{:on-message (fn [_ws msg _last?]
|
||||
{:headers {"User-Agent" "micro-blog-fetcher"}
|
||||
:on-message (fn [_ws msg _last?]
|
||||
(process-msg msg))
|
||||
:on-close (fn [_ws _status _reason]
|
||||
(println "WebSocket closed!"))})))
|
||||
:on-close (fn [_ws status reason]
|
||||
(tel/log! {:level :warn :data {:status status :reason reason}} "WebSocket connection closed"))})))
|
||||
|
||||
(defn subscribe-to-author [pubkey since]
|
||||
(let [sub-id (@config :nostr-fetcher-id)
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@
|
|||
(utils/validate-with-throw post save-post-schema)
|
||||
(tel/log! {:level :info :data {:remoteId (:remoteId post)}} "Post passed save validation")
|
||||
(if (post-with-remote-id-already-saved? (:remoteId post))
|
||||
(println "post already saved")
|
||||
(tel/log! {:level :warn :data {:remoteId (:remoteId post)}} "Post already saved, skipping")
|
||||
(try
|
||||
(http-client/post (str (@config :pocket-base-host) "/api/collections/micro_blog_posts/records")
|
||||
{:headers {"Authorization" (get-login-token-with-cache)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue