-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEventlogJSON.hs
30 lines (24 loc) · 969 Bytes
/
EventlogJSON.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE TemplateHaskell #-}
module EventlogJSON where
import Data.Aeson (FromJSON(..), ToJSON(..))
import Data.Aeson.TH
import qualified Data.ByteString as BS
import qualified Data.ByteString.Base64 as Base64
import GHC.RTS.Events as GHC
instance FromJSON BS.ByteString where
parseJSON a = parseJSON a >>= either fail pure . Base64.decode
instance ToJSON BS.ByteString where
toJSON = toJSON . Base64.encode
toEncoding = toEncoding . Base64.encode
$(deriveJSON defaultOptions ''HeapProfFlags)
$(deriveJSON defaultOptions ''KernelThreadId)
$(deriveJSON defaultOptions ''HeapProfBreakdown)
$(deriveJSON defaultOptions ''ThreadStopStatus)
$(deriveJSON defaultOptions ''CapsetType)
$(deriveJSON defaultOptions ''MessageTag)
$(deriveJSON defaultOptions ''EventType)
$(deriveJSON defaultOptions ''EventInfo)
$(deriveJSON defaultOptions ''Event)
$(deriveJSON defaultOptions ''Data)
$(deriveJSON defaultOptions ''Header)
$(deriveJSON defaultOptions ''EventLog)