Unify "out: <url>" logging to a function
This commit is contained in:
parent
10cdd260e0
commit
ece762fc5b
6 changed files with 15 additions and 6 deletions
|
@ -26,6 +26,7 @@
|
|||
(canonical_origin . "")
|
||||
(debug . "false")
|
||||
(instance_is_official . "false") ; please don't turn this on, or you will make me very upset
|
||||
(log_outgoing . "true")
|
||||
(port . "10416")
|
||||
(strict_proxy . "true")))
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
("siprop" . "rightsinfo")
|
||||
("format" . "json")
|
||||
("formatversion" . "2")))))
|
||||
(printf "out: ~a~n" dest-url)
|
||||
(log-outgoing dest-url)
|
||||
(define res (easy:get dest-url))
|
||||
(define data (easy:response-json res))
|
||||
(license (jp "/query/rightsinfo/text" data)
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
("cmlimit" . "max")
|
||||
("formatversion" . "2")
|
||||
("format" . "json")))))
|
||||
(printf "out: ~a~n" dest-url)
|
||||
(log-outgoing dest-url)
|
||||
(define dest-res (easy:get dest-url #:timeouts timeouts))
|
||||
(easy:response-json dest-res)]
|
||||
[page-data (define dest-url
|
||||
|
@ -86,7 +86,7 @@
|
|||
("prop" . "text|headhtml|langlinks")
|
||||
("formatversion" . "2")
|
||||
("format" . "json")))))
|
||||
(printf "out: ~a~n" dest-url)
|
||||
(log-outgoing dest-url)
|
||||
(define dest-res (easy:get dest-url #:timeouts timeouts))
|
||||
(easy:response-json dest-res)]
|
||||
[license (license-auto wikiname)])
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
("format" . "json")))))
|
||||
|
||||
(thread-let
|
||||
([dest-res (printf "out: ~a~n" dest-url)
|
||||
([dest-res (log-outgoing dest-url)
|
||||
(easy:get dest-url #:timeouts timeouts)]
|
||||
[license (license-auto wikiname)])
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@
|
|||
("prop" . "text|headhtml|langlinks")
|
||||
("formatversion" . "2")
|
||||
("format" . "json")))))
|
||||
(printf "out: ~a~n" dest-url)
|
||||
(log-outgoing dest-url)
|
||||
(easy:get dest-url #:timeouts timeouts)]
|
||||
[license (license-auto wikiname)])
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#lang typed/racket/base
|
||||
(require racket/string
|
||||
"pure-utils.rkt")
|
||||
(require/typed "config.rkt" [config-true? (Symbol -> Boolean)])
|
||||
|
||||
(provide
|
||||
; make a query string from an association list of strings
|
||||
|
@ -8,7 +9,9 @@
|
|||
; make a proxied version of a fandom url
|
||||
u-proxy-url
|
||||
; check whether a url is on a domain controlled by fandom
|
||||
is-fandom-url?)
|
||||
is-fandom-url?
|
||||
; prints "out: <url>"
|
||||
log-outgoing)
|
||||
|
||||
(module+ test
|
||||
(require "typed-rackunit.rkt"))
|
||||
|
@ -69,3 +72,8 @@
|
|||
is-fandom-url?
|
||||
(λ ([v : String]) (string-append "/proxy?" (params->query `(("dest" . ,url)))))
|
||||
url))
|
||||
|
||||
(: log-outgoing (String -> Void))
|
||||
(define (log-outgoing url-string)
|
||||
(when (config-true? 'log_outgoing)
|
||||
(printf "out: ~a~n" url-string)))
|
||||
|
|
Loading…
Reference in a new issue