diff options
Diffstat (limited to 'src/Network/BitTorrent/PeerWire/Message.hs')
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Message.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Network/BitTorrent/PeerWire/Message.hs b/src/Network/BitTorrent/PeerWire/Message.hs index f5ad2693..6515fdf2 100644 --- a/src/Network/BitTorrent/PeerWire/Message.hs +++ b/src/Network/BitTorrent/PeerWire/Message.hs | |||
@@ -1,3 +1,4 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
1 | module Network.BitTorrent.PeerWire.Message | 2 | module Network.BitTorrent.PeerWire.Message |
2 | ( Message(..) | 3 | ( Message(..) |
3 | , Bitfield | 4 | , Bitfield |
@@ -7,6 +8,7 @@ module Network.BitTorrent.PeerWire.Message | |||
7 | import Control.Applicative | 8 | import Control.Applicative |
8 | import qualified Data.ByteString as B | 9 | import qualified Data.ByteString as B |
9 | import Data.Serialize | 10 | import Data.Serialize |
11 | import Text.PrettyPrint | ||
10 | import Network | 12 | import Network |
11 | 13 | ||
12 | import Network.BitTorrent.PeerWire.Block | 14 | import Network.BitTorrent.PeerWire.Block |
@@ -141,10 +143,10 @@ instance Serialize Message where | |||
141 | -- compact and suitable for logging: only useful information but not | 143 | -- compact and suitable for logging: only useful information but not |
142 | -- payload bytes. | 144 | -- payload bytes. |
143 | -- | 145 | -- |
144 | ppMessage :: Message -> String | 146 | ppMessage :: Message -> Doc |
145 | ppMessage (Bitfield _) = "Bitfield " | 147 | ppMessage (Bitfield _) = "Bitfield" |
146 | ppMessage (Piece blk) = "Piece " ++ ppBlock blk | 148 | ppMessage (Piece blk) = "Piece" <+> ppBlock blk |
147 | ppMessage (Cancel ix) = "Cancel " ++ ppBlockIx ix | 149 | ppMessage (Cancel ix) = "Cancel" <+> ppBlockIx ix |
148 | ppMessage (SuggestPiece pix) = "Suggest" ++ show pix | 150 | ppMessage (SuggestPiece pix) = "Suggest" <+> int pix |
149 | ppMessage (RejectRequest ix) = "Reject" ++ ppBlockIx ix | 151 | ppMessage (RejectRequest ix) = "Reject" <+> ppBlockIx ix |
150 | ppMessage msg = show msg \ No newline at end of file | 152 | ppMessage msg = text (show msg) \ No newline at end of file |