Handle PING messages

Also add logging for outgoing messages.