Skip to content
Browse files

Use define-logger new in Racket 5.3.1

  • Loading branch information...
1 parent 1060484 commit 4495f147a545e7a0046c10f1837d2c3899929b7e @greghendershott committed Dec 3, 2012
Showing with 22 additions and 13 deletions.
  1. +1 −1 cw.rkt
  2. +1 −1 exn.rkt
  3. +1 −1 glacier.rkt
  4. +1 −1 info.rkt
  5. +3 −3 post.rkt
  6. +4 −4 s3.rkt
  7. +2 −2 ses.rkt
  8. +9 −0 util.rkt
View
2 cw.rkt
@@ -37,7 +37,7 @@
(dict->form-urlencoded all-params)))
(define signature (sha256-encode str-to-sign))
(define signed-params (append all-params `((Signature ,signature))))
- (log-debug (format "~a" signed-params))
+ (log-aws-debug (format "~a" signed-params))
(define head
`([Content-Type "application/x-www-form-urlencoded; charset=utf-8"]))
(define uri (endpoint->uri (cw-endpoint) "/"))
View
2 exn.rkt
@@ -48,7 +48,7 @@
(define/contract/provide (header&response->exn:fail:aws h e ccm)
(string? (or/c bytes? xexpr?) continuation-mark-set? . -> . exn:fail:aws?)
- (log-debug (format "~a ~a" h e))
+ (log-aws-debug (format "~a ~a" h e))
(define http-code (extract-http-code h))
(define http-text (extract-http-text h))
(define content-type (extract-field "Content-Type" h))
View
2 glacier.rkt
@@ -273,7 +273,7 @@
;; Returns #t unless it throws an exception.
(define/contract (upload-part name upload-id offset data)
(string? string? exact-nonnegative-integer? bytes? . -> . void)
- (log-debug (format "upload-part ~a-~a" offset (+ offset (bytes-length data))))
+ (log-aws-debug (format "upload-part ~a-~a" offset (+ offset (bytes-length data))))
(define m "PUT")
(define u (string-append "http://" host "/-/vaults/" name
"/multipart-uploads/" upload-id))
View
2 info.rkt
@@ -14,5 +14,5 @@
(define primary-file '("main.rkt"))
(define scribblings '(("manual.scrbl" (multi-page))))
-(define required-core-version "5.3")
+(define required-core-version "5.3.1")
(define repositories '("4.x"))
View
6 post.rkt
@@ -13,7 +13,7 @@
. ->* .
xexpr?)
(define data (string->bytes/utf-8 (dict->form-urlencoded xs-post-data)))
- (log-debug (tr "POST" data))
+ (log-aws-debug (tr "POST" data))
(call/output-request
"1.1" "POST" uri data #f heads
(lambda (in h)
@@ -23,8 +23,8 @@
[503
(if (<= try 5)
(let ([sleep-time (sqr try)]) ;wait longer each time
- (log-info (format "AWS returned 503. Try ~a in ~a secs."
- (add1 try) sleep-time))
+ (log-aws-info (format "AWS returned 503. Try ~a in ~a secs."
+ (add1 try) sleep-time))
(sleep sleep-time)
(post-with-retry uri xs-post-data heads (add1 try)))
(error 'post-with-retry "too many 503 retries; giving up"))]
View
8 s3.rkt
@@ -329,8 +329,8 @@
(dict?)
. ->* . string?)
(when (> data-len 100MB)
- (log-warning (tr "S3 `put' where " data-len
- "(when > 100 MB, consider using `multipart-put')")))
+ (log-aws-warning (tr "S3 `put' where " data-len
+ "(when > 100 MB, consider using `multipart-put')")))
(define-values (u h)
(uri&headers bucket+path
"PUT"
@@ -426,7 +426,7 @@
(define (get-part part-num)
;; Each get-part does its own file open, so we're OK to
;; position/read the same file from multiple threads.
- (log-debug (tr "get-part" part-num part-size num-parts))
+ (log-aws-debug (tr "get-part" part-num part-size num-parts))
(define (read-part in)
(file-position in (* part-num part-size))
(read-bytes part-size in))
@@ -478,7 +478,7 @@
;; Check the response XML to see if
;; truly succeeded.
(when (first-tag-value x 'Error)
- (log-fatal (tr x))
+ (log-aws-fatal (tr x))
(raise (header&response->exn:fail:aws
h x (current-continuation-marks))))
x)))
View
4 ses.rkt
@@ -59,7 +59,7 @@
(define/contract/provide (send-raw-email mail-from rcpt-to raw-message)
(string? (listof string?) string? . -> . xexpr?)
- (log-debug raw-message)
+ (log-aws-debug raw-message)
(define source ;use Return-Path if present else MAIL FROM
(match raw-message
[(regexp #rx"(?i:Return-Path:)[ ]*([^\r\n]+)" (list _ x)) x]
@@ -149,7 +149,7 @@
(match exn
[(exn:fail:aws _ _ 400 _ "Throttling" "Maximum sending rate exceeded.")
(define secs (add1 (* (random) 15))) ;1-16 seconds
- (log-warning (format "~a. Will retry in ~a seconds." exn secs))
+ (log-aws-warning (format "~a. Will retry in ~a seconds." exn secs))
(sleep secs)
(request params)]
[else (raise exn)])]))))
View
9 util.rkt
@@ -205,3 +205,12 @@
(module+ test
(check-equal? (true-value-pairs 'a 1 'b #f 'c 2)
(list 'a 1 'c 2)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-logger aws)
+(provide log-aws-fatal
+ log-aws-error
+ log-aws-warning
+ log-aws-info
+ log-aws-debug)

0 comments on commit 4495f14

Please sign in to comment.
Something went wrong with that request. Please try again.