on master help sign in
Fix warnings
commita3842dedc60e2c0c7f09b47ef6102fb9f649b52b authorOzgun Ataman <ozgun.ataman@soostone.com> dateSat 28 Feb 2015, 21:55 (12 years ago) parent0940f2e
4 files changed+14−17
TODO.org+2 katip.cabal+6−8 src/Katip/Core.hs+4−4 src/Katip/Scribes/Handle.hs+2−5
TODO.org+2
@@ -2,6 +2,8 @@
22
33* TODOs
44
5+** TODO Should we remove orphan IO instance and add a LoggingT?
6+
57** DONE Add a "Maybe LocInfo" using a TH version of logF
68 CLOSED: [2015-02-28 Sat 21:23]
79** DONE Log current PID in Item
katip.cabal+6−8
@@ -1,16 +1,13 @@
1−-- Initial soothsayer.cabal generated by cabal init. For further
2−-- documentation, see http://haskell.org/cabal/users-guide/
3−
41name: katip
52version: 0.1.0.0
6−-- synopsis:
7−-- description:
3+synopsis: A structured logging framework for tagging each log message with its
4+ surrounding context.
85license: BSD3
96license-file: LICENSE
107author: Ozgun Ataman
118maintainer: ozgun.ataman@soostone.com
12−copyright: Soostone Inc
13−category: Data
9+copyright: Soostone Inc, 2015
10+category: Data, Text, Logging
1411build-type: Simple
1512cabal-version: >=1.10
1613
@@ -51,4 +48,5 @@ library
5148 , unordered-containers >= 0.2 && < 0.3
5249
5350 hs-source-dirs: src
54− default-language: Haskell2010
51+ default-language: Haskell2010
52+ ghc-optoions: -Wall
src/Katip/Core.hs+4−4
@@ -138,8 +138,8 @@ instance ToJSON LocJs where
138138 toJSON (LocJs (Loc fn p m (l, c) _)) = A.object
139139 [ "loc_fn" A..= fn
140140 , "loc_pkg" A..= p
141− , "loc_mod" A..= l
142− , "loc_ln" A..= c
141+ , "loc_mod" A..= m
142+ , "loc_ln" A..= l
143143 , "loc_col" A..= c
144144 ]
145145
@@ -164,10 +164,10 @@ instance LogContext () where payloadKeys _ _ = SomeKeys []
164164-------------------------------------------------------------------------------
165165-- | Constrain payload based on verbosity. To be used by backends.
166166payloadJson :: LogContext a => Verbosity -> a -> A.Value
167−payloadJson v a = case payloadKeys v a of
167+payloadJson verb a = case payloadKeys verb a of
168168 AllKeys -> toJSON a
169169 SomeKeys ks -> toJSON a
170− & _Object %~ HM.filterWithKey (\ k v -> k `elem` ks)
170+ & _Object %~ HM.filterWithKey (\ k _ -> k `elem` ks)
171171
172172
173173-------------------------------------------------------------------------------
src/Katip/Scribes/Handle.hs+2−5
@@ -8,13 +8,10 @@ module Katip.Scribes.Handle
88import Blaze.ByteString.Builder
99import Blaze.ByteString.Builder.Char.Utf8
1010import Control.Lens
11−import Data.Aeson (ToJSON (..))
1211import Data.Aeson.Lens
1312import qualified Data.ByteString.Char8 as B
1413import qualified Data.HashMap.Strict as HM
15−import Data.Maybe
1614import Data.Monoid
17−import Data.Text (Text)
1815import Data.Time
1916import System.IO
2017import System.IO.Unsafe (unsafePerformIO)
@@ -31,14 +28,14 @@ brackets m = fromByteString "[" <> m <> fromByteString "]"
3128
3229-------------------------------------------------------------------------------
3330getKeys :: LogContext s => Verbosity -> s -> [Builder]
34−getKeys v a = payloadJson v a ^..
31+getKeys verb a = payloadJson verb a ^..
3532 _Object . to HM.toList . traverse . to rendPair
3633 where
3734 rendPair (k,v) = fromText k <> fromText ":" <> (v ^. _Primitive . to renderPrim)
38− a' = toJSON a
3935
4036
4137-------------------------------------------------------------------------------
38+renderPrim :: Primitive -> Builder
4239renderPrim (StringPrim t) = fromText t
4340renderPrim (NumberPrim s) = fromString (show s)
4441renderPrim (BoolPrim b) = fromString (show b)