'Datagram transports implement L{ILoggingContext.logPrefix} to return a
message reflecting the protocol they are running.'

def test_logPrefix(self):

    class CustomLogPrefixDatagramProtocol(DatagramProtocol, ):
        def __init__(self, prefix):
            self._prefix = prefix
            self.system = Deferred()
        def logPrefix(self):
            return self._prefix
        def datagramReceived(self, bytes, addr):
            if (self.system is not None):
                system = self.system
                self.system = None
                system.callback(context.get(ILogContext)['system'])
    reactor = self.buildReactor()
    protocol = CustomLogPrefixDatagramProtocol('Custom    Datagrams')
    d = protocol.system
    port = self.getListeningPort(reactor, protocol)
    address = port.getHost()
    def gotSystem(system):
        self.assertEqual('Custom    Datagrams    (UDP)', system)
    d.addCallback(gotSystem)
    d.addErrback(err)
    d.addCallback((lambda ignored: reactor.stop()))
    port.write('some    bytes', ('127.0.0.1', address.port))
    self.runReactor(reactor)
