当前位置: 首页>>代码示例>>Golang>>正文


Golang log.SetPrefix函数代码示例

本文整理汇总了Golang中log.SetPrefix函数的典型用法代码示例。如果您正苦于以下问题:Golang SetPrefix函数的具体用法?Golang SetPrefix怎么用?Golang SetPrefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetPrefix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestUserModelCreate

func TestUserModelCreate(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	log.SetPrefix(util.GetCallerName() + " : ")
	getThisUser := dto.User{
		Name:  "Rate My First User",
		Email: "[email protected]",
		//Status:   dto.SetStatus(dto.INITIALIZED),
	}
	umodel := UserModel{}
	operation, _ := GetVDLOperation(umodel, "create")
	gotUser, retCode, err := umodel.Create(operation, &getThisUser)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	userId = (*gotUser).Id
	log.Printf("%s Successful for %#v", funcName, gotUser)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:28,代码来源:UserModel_test.go

示例2: TestUserModelUpdate

func TestUserModelUpdate(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	TestUserModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	getThisUser := dto.User{
		Email:  "[email protected]",
		Status: dto.SetStatus(dto.ACTIVE),
	}
	umodel := UserModel{}
	operation, _ := GetVDLOperation(umodel, "update")
	user_id := int64(userId)
	gotUser, retCode, err := umodel.Update(operation, user_id, &getThisUser)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	userId = (*gotUser).Id
	log.Printf("%s Successful for %#v", funcName, gotUser)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:29,代码来源:UserModel_test.go

示例3: main

func main() {
	flag.Parse()
	if *printLabel {
		// Short circuit execution to print the build label
		fmt.Println(buildLabel())
		return
	}

	var err error
	if *forceProxy || strings.HasSuffix(os.Args[0], "--proxy") {
		log.SetPrefix("git-remote-persistent-https--proxy: ")
		proxy := &Proxy{
			BuildLabel:         buildLabel(),
			MaxIdleDuration:    defaultMaxIdleDuration,
			PollUpdateInterval: defaultPollUpdateInterval,
		}
		err = proxy.Run()
	} else {
		log.SetPrefix("git-remote-persistent-https: ")
		client := &Client{
			ProxyBin: *proxyBin,
			Args:     flag.Args(),
		}
		err = client.Run()
	}
	if err != nil {
		log.Fatalln(err)
	}
}
开发者ID:205c,项目名称:git,代码行数:29,代码来源:main.go

示例4: TestMicroPageSvcDeletePage

func TestMicroPageSvcDeletePage(t *testing.T) {
	log.SetPrefix(util.GetCallerName() + ":")
	mps.Register(util.GetConfig().RootPath, util.GetConfig().ApiVersion, "/page")
	//mps.MicroSvc.AddModel(mockmodel.MockPageModel{})
	tests := []resttest.RESTTestContainer{
		{
			Desc:    "DeletePage",
			Handler: restful.DefaultContainer.ServeHTTP,
			Path:    "%1/%2",
			Sub: map[string]string{
				"%1": mps.MicroSvc.GetFullPath(),
				"%2": "3",
			},
			Method:          "DELETE",
			Status:          http.StatusOK,
			PreAuthId:       7,
			OwnThreshold:    0,
			GlobalThreshold: 0,
		},
	}
	//mod, _ := mps.MicroSvc.getModel(mps.MicroSvc.GetFullPath())
	//log.Println("----------------------------------------------------------------------------")
	//log.Printf("----- Testing with Model ( %s )---------------------", reflect.TypeOf(mod))
	//log.Println("----------------------------------------------------------------------------")
	//resttest.RunTestSet(t, tests)
	// Test w/Actual database
	mps.MicroSvc.AddModel(model.PageModel{})
	mod, _ := mps.MicroSvc.getModel(mps.MicroSvc.GetFullPath())
	log.Println("----------------------------------------------------------------------------")
	log.Printf("----- Testing with Model ( %s )---------------------", reflect.TypeOf(mod))
	log.Println("----------------------------------------------------------------------------")
	resttest.RunTestSet(t, tests)
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:34,代码来源:MicroPageSvc_test.go

示例5: SetPrefix

// SetPrefix delegates to standard log package SetPrefix and adds "[ ]" around the prefix
func SetPrefix(s string) {
	if s != "" {
		log.SetPrefix("[" + s + "] ")
	} else {
		log.SetPrefix("")
	}
}
开发者ID:DavidNix,项目名称:dlog,代码行数:8,代码来源:dlog.go

示例6: TestUserModelDelete

func TestUserModelDelete(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	TestUserModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	umodel := UserModel{}
	operation, _ := GetVDLOperation(umodel, "delete")
	user_id := int64(userId)
	gotUser, retCode, err := umodel.Delete(operation, user_id)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	userId = (*gotUser).Id
	log.Printf("%s Successful for %#v", funcName, gotUser)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:25,代码来源:UserModel_test.go

示例7: TestTagModelUpdateStatus

func TestTagModelUpdateStatus(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	TestTagModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	smodel := TagModel{}
	operation, _ := GetVDLOperation(smodel, "updatestatus")
	tag_id := int64(tagId)
	gotTag, retCode, err := smodel.UpdateStatus(operation, tag_id, dto.BANNED)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	tagId = (*gotTag).Id
	log.Printf("%s Successful for %#v", funcName, gotTag)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:25,代码来源:TagModel_test.go

示例8: TestSectionModelUpdate

func TestSectionModelUpdate(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	TestSectionModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	getThisSection := dto.Section{
		Name:     "Update My First Section",
		PageId:   pageId,
		OrderNum: 1,
		Status:   dto.SetStatus(dto.ACTIVE),
	}
	smodel := SectionModel{}
	operation, _ := GetVDLOperation(smodel, "update")
	section_id := int64(sectionId)
	gotSection, retCode, err := smodel.Update(operation, section_id, &getThisSection)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	sectionId = (*gotSection).Id
	log.Printf("%s Successful for %#v", funcName, gotSection)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:31,代码来源:SectionModel_test.go

示例9: logMsg

func logMsg(level string, L *lua.LState) int {
	old := log.Prefix()
	log.SetPrefix(level)
	tpl := L.CheckString(1)
	top := L.GetTop()

	// Optimization for the case where no formatter needs to be
	// applied.
	if top <= 1 {
		log.Print(tpl)
		log.SetPrefix(old)
		return 0
	}

	args := make([]interface{}, top-1)
	for i := 2; i <= top; i++ {
		args[i-2] = L.Get(i)
	}

	// FIXME: If more args are supplied than placeholders, this will
	// generate an error.
	log.Printf(tpl, args...)
	log.SetPrefix(old)
	return 0
}
开发者ID:andars,项目名称:caddy-lua,代码行数:25,代码来源:log.go

示例10: TestTagModelFindById

func TestTagModelFindById(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	TestTagModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	smodel := TagModel{}
	operation, _ := GetVDLOperation(smodel, "findbyid")
	tag_id := int64(tagId)
	gotSection, retCode, err := smodel.FindById(operation, tag_id)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	sectionId = (*gotSection).Id
	log.Printf("%s Successful for %#v", funcName, gotSection)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:25,代码来源:TagModel_test.go

示例11: Start

// Start the worker by starting a goroutine, that is an infinite "for-select" loop
func (w *Worker) Start() {
	runtime.SetFinalizer(w, finalizer)
	receivedQuitSignal := false

	go func() {
		for {
			if receivedQuitSignal == false {
				// Add ourselves into the worker queue if not going to stop
				w.WorkerQueue <- w.Work
			}

			select {
			case work := <-w.Work:
				// Receive a work request
				log.SetPrefix("[Worker " + strconv.Itoa(w.ID) + "] ")
				log.Printf("Received work request")

				w.Handler(w, work)

				if receivedQuitSignal != false {
					log.SetPrefix("[Worker " + strconv.Itoa(w.ID) + "] ")
					log.Printf("Terminating\n")
					return
				}
			case <-w.QuitChan:
				// Flag the worker to stop after next request
				// This is in order to remove the worker itself from WorkerQueue
				log.SetPrefix("[Worker " + strconv.Itoa(w.ID) + "] ")
				log.Printf("Going to stop after processing another work request\n")
				receivedQuitSignal = true
			}
		}
	}()
}
开发者ID:itscaro,项目名称:go-workers,代码行数:35,代码来源:worker.go

示例12: TestRevisionModelCreate

func TestRevisionModelCreate(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("---------------- Starting  Test ( %s )---------------------", funcName)
	TestUserModelCreate(t)
	TestSectionModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	getThisRevision := dto.Revision{
		SectionId: sectionId,
		Content:   "Content for my first revision <b>has tags</b>",
	}
	smodel := RevisionModel{}
	if gotRevision, retCode, err := smodel.Create("create_revision", userId, &getThisRevision); gotRevision == nil || err != nil {
		//if gotRevision == nil || err != nil {
		log.Fatalf(" RevisionModel Create Failed: %#v", err)
		count.FailCount++
		return
	} else {

		if got, want := retCode, 0; got != want {
			t.Errorf("RevisionModelCreate Broken: got  %d, wanted  %d", got, want)
			count.FailCount++
			return
		}
		revId = (*gotRevision).Id
		log.Printf("RevisionModel Create Successful for %#v", gotRevision)
		count.SuccessCount++
	}
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:29,代码来源:RevisionModel_test.go

示例13: TestMicroRevisionSvcCreateTagRelationship

func TestMicroRevisionSvcCreateTagRelationship(t *testing.T) {
	log.SetPrefix(util.GetCallerName() + " : ")
	mrs.Register(util.GetConfig().RootPath, util.GetConfig().ApiVersion, "/revision")
	mrs.MicroSvc.AddModel(model.RevisionModel{})
	mrs.MicroSvc.AddRelationship(reflect.TypeOf(dto.Tag{}), mockmodel.MockEntityRelationshipModel{})
	tests := []resttest.RESTTestContainer{
		{
			Desc:    "CreateTagRelationship",
			Handler: restful.DefaultContainer.ServeHTTP,
			Path:    "%1/%2/tag/%3",
			Sub: map[string]string{
				"%1": mrs.MicroSvc.GetFullPath(),
				"%2": "1",
				"%3": "1",
			},
			Method:          "PUT",
			Status:          http.StatusOK,
			PreAuthId:       7,
			OwnThreshold:    0,
			GlobalThreshold: 0,
		},
	}
	mod, _ := mrs.MicroSvc.getModel(mrs.MicroSvc.GetFullPath())
	rel := mrs.MicroSvc.getRelationship(reflect.TypeOf(dto.Tag{}))
	log.Println("----------------------------------------------------------------------------")
	log.Printf("----- Testing with Model ( %s )---------------------", reflect.TypeOf(mod))
	log.Printf("----- Testing with Relationship ( %s )---------------------", reflect.TypeOf(rel))
	log.Println("----------------------------------------------------------------------------")
	resttest.RunTestSet(t, tests)
	//// Test w/Actual database
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:32,代码来源:MicroRevisionSvc_test.go

示例14: TestTagModelCreate

func TestTagModelCreate(t *testing.T) {
	funcName := util.GetCallerName()
	log.Printf("%s ---------------- Starting  Test ---------------------", funcName)
	log.SetPrefix(util.GetCallerName() + " : ")
	getThisTag := dto.Tag{
		Name:        "test tag",
		Description: "Content for my first tag <b>has tags</b>",
		Status:      dto.SetStatus(dto.INITIALIZED),
	}
	smodel := TagModel{}
	operation, _ := GetVDLOperation(smodel, "create")
	gotTag, retCode, err := smodel.Create(operation, &getThisTag)
	if err != nil {
		log.Fatalf("%s Failed: %#v", funcName, err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("%s got  %d, wanted  %d", funcName, got, want)
		count.FailCount++
		return
	}
	tagId = (*gotTag).Id
	log.Printf("%s Successful for %#v", funcName, gotTag)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:28,代码来源:TagModel_test.go

示例15: TestPageModelCreate

func TestPageModelCreate(t *testing.T) {
	log.Printf("---------------- Starting  Test ( %s )---------------------", util.GetCallerName())
	TestUserModelCreate(t)
	log.SetPrefix(util.GetCallerName() + " : ")
	getThisPage := dto.Page{
		Title: "Rate My First Page",
	}
	pmodel := PageModel{}
	operation, _ := GetVDLOperation(pmodel, "create")
	author_id := int64(userId)
	gotPage, retCode, err := pmodel.Create(operation, author_id, &getThisPage)
	if err != nil {
		log.Fatalf(" PageModel Create Failed: %#v", err)
		count.FailCount++
		return
	}

	if got, want := retCode, 0; got != want {
		t.Errorf("PageModelCreate Broken: got  %d, wanted  %d", got, want)
		count.FailCount++
		return
	}
	pageId = (*gotPage).Id
	log.Printf("PageModel Create Successful for %#v", gotPage)
	count.SuccessCount++
	log.SetPrefix("")
}
开发者ID:sguzwf,项目名称:mertiwiki,代码行数:27,代码来源:PageModel_test.go


注:本文中的log.SetPrefix函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。