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