You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
878 B

package logm
import (
"testing"
)
//
func TestNew(t *testing.T) {
one := New()
two := New()
if one == two {
t.Error("new error")
}
ins := New(Option{
OutMode: File,
Path: "./logs",
})
ins.Info("some message")
}
func TestGet(t *testing.T) {
one := Get()
two := Get()
if one != two {
t.Error("get error")
}
}
func TestField(t *testing.T) {
one := Get()
one.WithField("key", []int{1, 2, 3}).Info("Fields")
one.WithFields(Fields{"key": "one", "hello": 123, "xxx": []int{1, 2, 3}}).Info("Fields")
}
func BenchmarkNew(b *testing.B) {
for i := 0; i < b.N; i++ {
New()
}
}
func BenchmarkGet(b *testing.B) {
for i := 0; i < b.N; i++ {
Get()
}
}
func BenchmarkLog_Info(b *testing.B) {
for i := 0; i < b.N; i++ {
ins := Get(Option{
OutMode: FilePerSize,
SizeMax: 0.5 * 1024 * 1024,
Path: "./logs",
})
ins.Info("some message")
}
}