From 7fc8cd9dcdf1b480d462335cc6bd30b7d035abfa Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Fri, 22 Aug 2025 15:18:22 +0200 Subject: [PATCH] add better websocker related logging --- src/micro_blog/nostr.clj | 9 +++++---- src/micro_blog/pocket_base.clj | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/micro_blog/nostr.clj b/src/micro_blog/nostr.clj index 35afe68..1aecdc5 100644 --- a/src/micro_blog/nostr.clj +++ b/src/micro_blog/nostr.clj @@ -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) diff --git a/src/micro_blog/pocket_base.clj b/src/micro_blog/pocket_base.clj index ab3f3ae..515ac85 100644 --- a/src/micro_blog/pocket_base.clj +++ b/src/micro_blog/pocket_base.clj @@ -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)}