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