katip-wai 0.1.2.1 → 0.1.2.2
raw patch · 3 files changed
+29/−10 lines, 3 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
Files
- CHANGELOG.md +9/−1
- katip-wai.cabal +2/−2
- src/Katip/Wai.hs +18/−7
CHANGELOG.md view
@@ -24,7 +24,13 @@ ## [Unreleased] +## [0.1.2.2] - 2023-06-29 +### Fixed++- Increased upper bound for `aeson`++ ## [0.1.2.1] - 2022-11-12 ### Added @@ -58,7 +64,9 @@ - Initial release -[unreleased]: https://github.com/Disco-Dave/katip-wai/compare/releases/0.1.2.1...HEAD++[unreleased]: https://github.com/Disco-Dave/katip-wai/compare/releases/0.1.2.2...HEAD+[0.1.2.2]: https://github.com/Disco-Dave/katip-wai/compare/releases/0.1.2.1...releases/0.1.2.2 [0.1.2.1]: https://github.com/Disco-Dave/katip-wai/compare/releases/0.1.2.0...releases/0.1.2.1 [0.1.2.0]: https://github.com/Disco-Dave/katip-wai/compare/releases/0.1.1.0...releases/0.1.2.0 [0.1.1.0]: https://github.com/Disco-Dave/katip-wai/compare/releases/0.1.0.0...releases/0.1.1.0
katip-wai.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: katip-wai-version: 0.1.2.1+version: 0.1.2.2 synopsis: WAI middleware for logging request and response info through katip. description: WAI middleware for logging request and response info through katip. Please see the README on GitHub at <https://github.com/Disco-Dave/katip-wai#readme>@@ -59,7 +59,7 @@ -Werror build-depends:- , aeson >=0.6 && <2.2+ , aeson >=0.6 && <2.3 , base >=4.7 && <5 , bytestring >=0.9 && <0.12 , http-types >=0.12 && <0.13
src/Katip/Wai.hs view
@@ -1,18 +1,19 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} -- |---Description: Middleware for logging request and response info through Katip.+-- Description: Middleware for logging request and response info through Katip. -----Add information about 'Wai.Request', 'Wai.response', and the elapsed time to Katip's 'Katip.LogContexts'.+-- Add information about 'Wai.Request', 'Wai.Response', and the elapsed time to Katip's 'Katip.LogContexts'. -----The following is added to the context as \"response\":+-- The following is added to the context as \"response\": ----- - \"elapsedTimeInNanoSeconds\": Amount of time from receiving the request to sending the response in nano seconds.+-- - \"elapsedTimeInNanoSeconds\": Amount of time from receiving the request to sending the response in nano seconds. ----- - \"status\": The status of the response, ie. 200, 202, 204, 400, 404, 500, etc.+-- - \"status\": The status of the response, ie. 200, 202, 204, 400, 404, 500, etc. module Katip.Wai ( -- * Middleware defaultFormat@@ -62,8 +63,13 @@ , requestHeaderRange :: Maybe ByteString } -+#if MIN_VERSION_aeson(2,2,0)+requestToKeyValues :: Aeson.KeyValue e kv => Request -> [kv]+#else requestToKeyValues :: Aeson.KeyValue kv => Request -> [kv]+#endif++ requestToKeyValues Request{..} = let toText = decodeUtf8With lenientDecode headers =@@ -142,8 +148,13 @@ , responseStatus :: Status } -+#if MIN_VERSION_aeson(2,2,0)+responseToKeyValues :: Aeson.KeyValue e kv => Response -> [kv]+#else responseToKeyValues :: Aeson.KeyValue kv => Response -> [kv]+#endif++ responseToKeyValues Response{..} = [ "elapsedTimeInNanoSeconds" .= Clock.toNanoSecs responseElapsedTime , "status" .= fromEnum responseStatus