2022-06-17 16:09:23 +00:00
|
|
|
package canonicallog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-06-24 14:46:19 +00:00
|
|
|
"net"
|
2022-06-17 16:09:23 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-08-17 07:38:18 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/test"
|
|
|
|
|
2022-06-30 18:18:49 +00:00
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2022-06-17 16:09:23 +00:00
|
|
|
"github.com/multiformats/go-multiaddr"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLogs(t *testing.T) {
|
2022-06-30 18:18:49 +00:00
|
|
|
err := logging.SetLogLevel("canonical-log", "info")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-06-17 16:09:23 +00:00
|
|
|
LogMisbehavingPeer(test.RandPeerIDFatal(t), multiaddr.StringCast("/ip4/1.2.3.4"), "somecomponent", fmt.Errorf("something"), "hi")
|
|
|
|
|
2022-06-24 14:46:19 +00:00
|
|
|
netAddr := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 80}
|
2022-06-30 18:18:49 +00:00
|
|
|
LogMisbehavingPeerNetAddr(test.RandPeerIDFatal(t), netAddr, "somecomponent", fmt.Errorf("something"), "hello \"world\"")
|
|
|
|
|
|
|
|
LogPeerStatus(1, test.RandPeerIDFatal(t), multiaddr.StringCast("/ip4/1.2.3.4"), "extra", "info")
|
2022-06-24 14:46:19 +00:00
|
|
|
}
|