X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=tt.rkt;h=19397e2edade88f2a93ab26feefb636579bebbe3;hb=b8b29fbb27481dd8b1475f5714bfbc61d266dacb;hp=a375c69f05aaa1f979741ec96ceb99bed5b72ee6;hpb=b39ba7bee95268e33eddab23bf19583a66f8c123;p=tt.git diff --git a/tt.rkt b/tt.rkt index a375c69..19397e2 100644 --- a/tt.rkt +++ b/tt.rkt @@ -153,7 +153,7 @@ local-time?)]) (+ ts-epoch tz-offset))] [_ - (log-error "Invalid timestamp: ~v" ts) + (log-debug "Invalid timestamp: ~v" ts) #f])))) (: str->msg (-> (Option String) Url String (Option Msg))) @@ -164,7 +164,7 @@ (with-handlers* ([exn:fail? (λ (e) - (log-error + (log-debug "Failed to parse msg: ~v, from: ~v, at: ~v, because: ~v" str-head nick (url->string uri) e) #f)]) @@ -180,7 +180,7 @@ (regexp-match* #px"@<[^\\s]+([\\s]+)?[^>]+>" text))]) (Msg ts-epoch ts-orig nick uri text mentions)) (begin - (log-error + (log-debug "Msg rejected due to invalid timestamp: ~v, nick:~v, uri:~v" str-head nick (url->string uri)) #f)))] @@ -291,7 +291,7 @@ (if (file-exists? path-v2) (file->string path-v2) (begin - (log-warning "Cache file not found for URI: ~a" (url->string uri)) + (log-debug "Cache file not found for URI: ~a" (url->string uri)) #f))) (: str->url (-> String (Option String))) @@ -319,7 +319,7 @@ #f] [url (Peer nick url comment)])] [_ - (log-error "Invalid peer string: ~v" str) + (log-debug "Invalid peer string: ~v" str) #f])) (module+ test @@ -468,22 +468,22 @@ (log-debug "Last-Modified <= current skipping the rest of ~v" u-str) #t)))) (if (not cached?) - (begin - (log-debug - "Downloading the rest of ~v. ETag: ~a, Last-Modified: ~v" - u-str etag lmod) - (make-parent-directory* cached-object-path) - (make-parent-directory* cached-etag-path) - (make-parent-directory* cached-lmod-path) - (call-with-output-file cached-object-path - (curry copy-port body-input) - #:exists 'replace) - (when etag - (display-to-file etag cached-etag-path #:exists 'replace)) - (when lmod - (display-to-file lmod cached-lmod-path #:exists 'replace)) - 'downloaded-new) - 'skipped-cached)) + (begin + (log-debug + "Downloading the rest of ~v. ETag: ~a, Last-Modified: ~v" + u-str etag lmod) + (make-parent-directory* cached-object-path) + (make-parent-directory* cached-etag-path) + (make-parent-directory* cached-lmod-path) + (call-with-output-file cached-object-path + (curry copy-port body-input) + #:exists 'replace) + (when etag + (display-to-file etag cached-etag-path #:exists 'replace)) + (when lmod + (display-to-file lmod cached-lmod-path #:exists 'replace)) + 'downloaded-new) + 'skipped-cached)) (: uri-download (-> Positive-Float Url @@ -564,7 +564,7 @@ (: peer->msgs (-> Peer (Listof Msg))) (define (peer->msgs peer) (match-define (Peer nick uri _) peer) - (log-info "Reading peer nick:~v uri:~v" nick (url->string uri)) + (log-debug "Reading peer nick:~v uri:~v" nick (url->string uri)) (define msgs-data (uri-read-cached uri)) (if msgs-data (str->msgs nick uri msgs-data) @@ -646,7 +646,7 @@ (append* (map (λ (filename) (define path (build-path cache-object-dir filename)) (define size (/ (file-size path) 1000000.0)) - (log-info "BEGIN parsing ~a MB from file: ~v" + (log-debug "BEGIN parsing ~a MB from file: ~v" size (path->string path)) (define t0 (current-inexact-milliseconds)) @@ -656,12 +656,12 @@ (filter-comments (file->lines path)))) (define t1 (current-inexact-milliseconds)) - (log-info "END parsing ~a MB in ~a seconds from file: ~v." + (log-debug "END parsing ~a MB in ~a seconds from file: ~v." size (* 0.001 (- t1 t0)) (path->string path)) (when (empty? m) - (log-warning "No messages found in ~a" (path->string path))) + (log-debug "No messages found in ~a" (path->string path))) m) (directory-list cache-object-dir)))) (uniq (append* (map Msg-mentions msgs)))) @@ -705,7 +705,7 @@ "r, read : Read the timeline (offline operation)." "d, download : Download the timeline." ; TODO Add path dynamically - "u, upload : Upload your twtxt file (alias to execute ~/.tt/upload)." + "u, upload : Upload your twtxt file (alias to execute ~/.tt/hooks/upload)." "c, crawl : Discover new peers mentioned by known peers (offline operation)." "" #:args (command . args) @@ -739,7 +739,7 @@ #:program "tt upload" #:args () - (if (system (path->string (build-path tt-home-dir "upload"))) + (if (system (path->string (build-path tt-home-dir "hooks" "upload"))) (exit 0) (exit 1)))] [(or "r" "read")