Exemple #1
0
func TestMemoryPush(t *testing.T) {
	memBuf := NewMemoryBuffer()
	var item log.LogItem
	item.ID = 1
	item.Time = time.Now()
	item.Tag = log.DefaultTag
	item.Level = log.DEBUG
	item.Message = "Test message..."
	memBuf.Push(item)
	lItem, _ := memBuf.Pop()
	t.Log(lItem)
	lItem, _ = memBuf.Front()
	t.Log(lItem)
}
Exemple #2
0
func TestRedisPush(t *testing.T) {
	config := log.RedisConfig{
		Addr: "192.168.33.70:6379",
		DB:   1,
	}
	redisBuf := NewRedisBuffer(config)
	var item log.LogItem
	item.ID = 1
	item.Time = time.Now()
	item.Tag = log.DefaultTag
	item.Level = log.DEBUG
	item.Message = "Test redis message..."
	err := redisBuf.Push(item)
	if err != nil {
		t.Error(err)
		return
	}
	t.Log("Success")
}
Exemple #3
0
func TestMongoStore(t *testing.T) {
	var cfg log.MongoConfig
	cfg.URL = "mongodb://192.168.33.70:27017"
	store := NewMongoStore(cfg)
	var err error
	for i := 0; i < 1000; i++ {
		var item log.LogItem
		item.ID = uint64(i)
		item.Time = time.Now()
		item.Level = log.INFO
		item.Tag = log.DefaultTag
		item.Message = ".........................."
		err = store.Store(&item)
		if err != nil {
			break
		}
	}
	if err != nil {
		t.Error(err)
		return
	}
	t.Log("Write success.")
}