#lang racket/base
(require racket/contract
racket/path)
(define-struct logger (semaphore logfile-path))
(define (-make-logger logfile-path)
(make-logger (make-semaphore 1)
(normalize-path logfile-path)))
(define (logger-add! a-logger client-ip asset-zip-bytes other-attributes)
(call-with-semaphore
(logger-semaphore a-logger)
(lambda ()
(call-with-output-file (logger-logfile-path a-logger)
(lambda (op)
(write `((time ,(current-inexact-milliseconds))
(client-ip ,client-ip)
(asset-zip-bytes ,asset-zip-bytes)
(other-attributes ,other-attributes))
op)
(newline op))
#:exists 'append))))
(provide/contract
[logger? (any/c . -> . boolean?)]
[rename -make-logger make-logger (path-string? . -> . logger?)]
[logger-add! (logger? string? bytes? any/c . -> . any)])