@@ -180,7 +180,7 @@ instance FromJSON Severity where
180-------------------------------------------------------------------------------
180-------------------------------------------------------------------------------
181-- | Log message with Builder underneath; use '<>' to concat in O(1).
181-- | Log message with Builder underneath; use '<>' to concat in O(1).
182newtype LogStr = LogStr { unLogStr :: B.Builder }
182newtype LogStr = LogStr { unLogStr :: B.Builder }
183− deriving (Generic, Show)
183+ deriving (Generic, Show, Eq)
185instance IsString LogStr where
185instance IsString LogStr where
186 fromString = LogStr . B.fromString
186 fromString = LogStr . B.fromString
@@ -247,31 +247,62 @@ data Item a = Item {
247 } deriving (Generic, Functor)
247 } deriving (Generic, Functor)
248makeLenses ''Item
248makeLenses ''Item
250+-- Manual instance because 'Loc' has no 'Eq' and 'Show' instances in old
251+-- versions of template-haskell (< 2.10)
252+instance Eq a => Eq (Item a) where
253+ a == b = FT.and [ _itemApp a == _itemApp b
254+ , _itemEnv a == _itemEnv b
255+ , _itemSeverity a == _itemSeverity b
256+ , _itemThread a == _itemThread b
257+ , _itemHost a == _itemHost b
258+ , _itemProcess a == _itemProcess b
259+ , _itemPayload a == _itemPayload b
260+ , _itemMessage a == _itemMessage b
261+ , _itemTime a == _itemTime b
262+ , _itemNamespace a == _itemNamespace b
263+ , case (_itemLoc a, _itemLoc b) of
264+ (Nothing, Nothing) -> True
265+ (Just l1, Just l2) -> FT.and [ loc_filename l1 == loc_filename l2
266+ , loc_package l1 == loc_package l2
267+ , loc_module l1 == loc_module l2
268+ , loc_start l1 == loc_start l2
269+ , loc_end l1 == loc_end l2
251instance Show a => Show (Item a) where
274instance Show a => Show (Item a) where
252− show Item{..} = "Item {_itemApp = " ++ show _itemApp ++ ", " ++
275+ showsPrec d Item{..} = showParen (d >= 11) ( showString "Item {"
253− "_itemEnv = " ++ show _itemEnv ++ ", " ++
276+ . field "_itemApp" _itemApp
277+ . field "_itemEnv" _itemEnv
254− "_itemSeverity = " ++ show _itemSeverity ++ ", " ++
278+ . field "_itemSeverity" _itemSeverity
255− "_itemThread = " ++ show _itemThread ++ ", " ++
279+ . field "_itemThread" _itemThread
256− "_itemHost = " ++ show _itemHost ++ ", " ++
280+ . field "_itemHost" _itemHost
257− "_itemProcess = " ++ show _itemProcess ++ ", " ++
281+ . field "_itemProcess" _itemProcess
258− "_itemPayload = " ++ show _itemPayload ++ ", " ++
282+ . field "_itemPayload" _itemPayload
259− "_itemMessage = " ++ show _itemMessage ++ ", " ++
283+ . field "_itemMessage" _itemMessage
260− "_itemTime = " ++ show _itemTime ++ ", " ++
284+ . field "_itemTime" _itemTime
261− "_itemNamespace = " ++ show _itemNamespace ++ ", " ++
285+ . field "_itemNamespace" _itemNamespace
262− "_itemLoc = " ++ show (LocShow <$> _itemLoc) ++ "}"
286+ . showString "_itemLoc = " . shows (LocShow <$> _itemLoc)
290+ field n v = showString n . showString " = " . shows v . showString ", "
265newtype LocShow = LocShow Loc
292newtype LocShow = LocShow Loc
268instance Show LocShow where
295instance Show LocShow where
269− show (LocShow Loc{..}) =
296+ showsPrec d (LocShow Loc{..}) = showParen (d >= 11) ( showString "Loc {"
270− "Loc {loc_filename = " ++ show loc_filename ++ ", " ++
297+ . field "loc_filename" loc_filename
271− "loc_package = " ++ show loc_package ++ ", " ++
298+ . field "loc_package" loc_package
272− "loc_module = " ++ show loc_module ++ ", " ++
299+ . field "loc_module" loc_module
273− "loc_start = " ++ show loc_start ++ ", " ++
300+ . field "loc_start" loc_start
274− "loc_end = " ++ show loc_end ++ "}"
301+ . showString "loc_end = " . shows loc_end
305+ field n v = showString n . showString " = " . shows v . showString ", "
277instance ToJSON a => ToJSON (Item a) where
308instance ToJSON a => ToJSON (Item a) where
@@ -629,6 +660,7 @@ spawnScribeWorker (Scribe write _) queue = Async.async go
629data ScribeSettings = ScribeSettings {
660data ScribeSettings = ScribeSettings {
630 _scribeBufferSize :: Int
661 _scribeBufferSize :: Int
633makeLenses ''ScribeSettings
665makeLenses ''ScribeSettings