summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/PeerWire/Message.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/PeerWire/Message.hs')
-rw-r--r--src/Network/BitTorrent/PeerWire/Message.hs16
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 #-}
1module Network.BitTorrent.PeerWire.Message 2module Network.BitTorrent.PeerWire.Message
2 ( Message(..) 3 ( Message(..)
3 , Bitfield 4 , Bitfield
@@ -7,6 +8,7 @@ module Network.BitTorrent.PeerWire.Message
7import Control.Applicative 8import Control.Applicative
8import qualified Data.ByteString as B 9import qualified Data.ByteString as B
9import Data.Serialize 10import Data.Serialize
11import Text.PrettyPrint
10import Network 12import Network
11 13
12import Network.BitTorrent.PeerWire.Block 14import 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--
144ppMessage :: Message -> String 146ppMessage :: Message -> Doc
145ppMessage (Bitfield _) = "Bitfield " 147ppMessage (Bitfield _) = "Bitfield"
146ppMessage (Piece blk) = "Piece " ++ ppBlock blk 148ppMessage (Piece blk) = "Piece" <+> ppBlock blk
147ppMessage (Cancel ix) = "Cancel " ++ ppBlockIx ix 149ppMessage (Cancel ix) = "Cancel" <+> ppBlockIx ix
148ppMessage (SuggestPiece pix) = "Suggest" ++ show pix 150ppMessage (SuggestPiece pix) = "Suggest" <+> int pix
149ppMessage (RejectRequest ix) = "Reject" ++ ppBlockIx ix 151ppMessage (RejectRequest ix) = "Reject" <+> ppBlockIx ix
150ppMessage msg = show msg \ No newline at end of file 152ppMessage msg = text (show msg) \ No newline at end of file