當前位置: 首頁>>代碼示例>>Golang>>正文


Golang base.SetLogLevel函數代碼示例

本文整理匯總了Golang中github.com/couchbase/sync_gateway/base.SetLogLevel函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetLogLevel函數的具體用法?Golang SetLogLevel怎麽用?Golang SetLogLevel使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了SetLogLevel函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: BenchmarkChannelCacheUniqueDocs_Unordered

func BenchmarkChannelCacheUniqueDocs_Unordered(b *testing.B) {

	base.SetLogLevel(2) // disables logging
	context, _ := NewDatabaseContext("db", testBucket(), false, CacheOptions{})
	cache := newChannelCache(context, "Benchmark", 0)
	// generate docs
	docs := make([]*LogEntry, b.N)
	r := rand.New(rand.NewSource(99))
	for i := 0; i < b.N; i++ {
		docs[i] = e(uint64(i), fmt.Sprintf("long_document_id_for_sufficient_equals_complexity_%012d", i), "1-a")
	}
	// shuffle sequences
	for i := b.N - 1; i >= 0; i-- {
		j := int(r.Float64() * float64(b.N))
		oldSeq := docs[i].Sequence
		docs[i].Sequence = docs[j].Sequence
		docs[j].Sequence = oldSeq
	}

	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		cache.addToCache(docs[i], false)
	}
}
開發者ID:guoyu07,項目名稱:sync_gateway,代碼行數:25,代碼來源:channel_cache_test.go

示例2: BenchmarkChannelCacheRepeatedDocs80

func BenchmarkChannelCacheRepeatedDocs80(b *testing.B) {

	base.SetLogLevel(2) // disables logging
	context, _ := NewDatabaseContext("db", testBucket(), false, CacheOptions{})
	cache := newChannelCache(context, "Benchmark", 0)
	// generate doc IDs

	docIDs, revStrings := generateDocs(80.0, b.N)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		cache.addToCache(e(uint64(i), docIDs[i], revStrings[i]), false)
	}
}
開發者ID:guoyu07,項目名稱:sync_gateway,代碼行數:13,代碼來源:channel_cache_test.go

示例3: BenchmarkChannelCacheRepeatedDocs5

func BenchmarkChannelCacheRepeatedDocs5(b *testing.B) {

	base.SetLogLevel(2) // disables logging
	context := testBucketContext()
	cache := newChannelCache(context, "Benchmark", 0)
	// generate doc IDs

	docIDs, revStrings := generateDocs(5.0, b.N)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		cache.addToCache(e(uint64(i), docIDs[i], revStrings[i]), false)
	}
}
開發者ID:joeljeske,項目名稱:sync_gateway,代碼行數:13,代碼來源:channel_cache_test.go

示例4: BenchmarkDatabase

func BenchmarkDatabase(b *testing.B) {
	base.SetLogLevel(2) // disables logging
	for i := 0; i < b.N; i++ {
		bucket, _ := ConnectToBucket(base.BucketSpec{
			Server:     kTestURL,
			BucketName: fmt.Sprintf("b-%d", i)}, nil)
		context, _ := NewDatabaseContext("db", bucket, false, DatabaseContextOptions{})
		db, _ := CreateDatabase(context)

		body := Body{"key1": "value1", "key2": 1234}
		db.Put(fmt.Sprintf("doc%d", i), body)

		db.Close()
	}
}
開發者ID:joeljeske,項目名稱:sync_gateway,代碼行數:15,代碼來源:database_test.go

示例5: BenchmarkChannelCacheUniqueDocs_Ordered

func BenchmarkChannelCacheUniqueDocs_Ordered(b *testing.B) {

	base.SetLogLevel(2) // disables logging
	//base.SetLogLevel(2) // disables logging
	context, _ := NewDatabaseContext("db", testBucket(), false, CacheOptions{})
	cache := newChannelCache(context, "Benchmark", 0)
	// generate doc IDs
	docIDs := make([]string, b.N)
	for i := 0; i < b.N; i++ {
		docIDs[i] = fmt.Sprintf("long_document_id_for_sufficient_equals_complexity_%012d", i)
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		cache.addToCache(e(uint64(i), docIDs[i], "1-a"), false)
	}
}
開發者ID:guoyu07,項目名稱:sync_gateway,代碼行數:16,代碼來源:channel_cache_test.go

示例6: handleSetLogging

func (h *handler) handleSetLogging() error {
	body, err := h.readBody()
	if err != nil {
		return nil
	}
	if h.getQuery("level") != "" {
		base.SetLogLevel(int(getRestrictedIntQuery(h.rq.URL.Query(), "level", uint64(base.LogLevel()), 1, 3, false)))
		if len(body) == 0 {
			return nil // empty body is OK if request is just setting the log level
		}
	}
	var keys map[string]bool
	if err := json.Unmarshal(body, &keys); err != nil {
		return base.HTTPErrorf(http.StatusBadRequest, "Invalid JSON or non-boolean values")
	}
	base.UpdateLogKeys(keys, h.rq.Method == "PUT")
	return nil
}
開發者ID:arjunblue,項目名稱:sync_gateway,代碼行數:18,代碼來源:admin_api.go


注:本文中的github.com/couchbase/sync_gateway/base.SetLogLevel函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。