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


Golang log4go.Close函数代码示例

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


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

示例1: main

func main() {
	var err error
	// Parse cmd-line arguments
	flag.Parse()
	log.Info("web ver: \"%s\" start", ver.Version)
	if err = InitConfig(); err != nil {
		panic(err)
	}
	// Set max routine
	runtime.GOMAXPROCS(Conf.MaxProc)
	// init log
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	// init zookeeper
	zkConn, err := InitZK()
	if err != nil {
		if zkConn != nil {
			zkConn.Close()
		}
		panic(err)
	}
	// start pprof http
	perf.Init(Conf.PprofBind)
	// start http listen.
	StartHTTP()
	// process init
	if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
		panic(err)
	}
	// init signals, block wait signals
	signalCH := InitSignal()
	HandleSignal(signalCH)
	log.Info("web stop")
}
开发者ID:Terry-Mao,项目名称:gopush-cluster,代码行数:34,代码来源:main.go

示例2: Must

func (c *Client) Must(result *Result, err *AppError) *Result {
	if err != nil {
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}

	return result
}
开发者ID:AlexYIN,项目名称:platform,代码行数:9,代码来源:client.go

示例3: MustGeneric

// MustGeneric is a convenience function used for testing.
func (c *Client) MustGeneric(result interface{}, err *AppError) interface{} {
	if err != nil {
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}

	return result
}
开发者ID:loafoe,项目名称:platform,代码行数:10,代码来源:client.go

示例4: Must

func Must(sc StoreChannel) interface{} {
	r := <-sc
	if r.Err != nil {
		l4g.Close()
		time.Sleep(time.Second)
		panic(r.Err)
	}

	return r.Data
}
开发者ID:fallenby,项目名称:platform,代码行数:10,代码来源:store.go

示例5: UpdateUserToTeamAdmin

func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
	utils.DisableDebugLogForTest()

	tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_ADMIN}
	if tmr := <-Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
		l4g.Error(tmr.Err.Error())
		l4g.Close()
		time.Sleep(time.Second)
		panic(tmr.Err)
	}
}
开发者ID:ReinhardHsu,项目名称:platform,代码行数:11,代码来源:apitestlib.go

示例6: LinkUserToTeam

func LinkUserToTeam(user *model.User, team *model.Team) {
	utils.DisableDebugLogForTest()

	err := JoinUserToTeam(team, user)
	if err != nil {
		l4g.Error(err.Error())
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}

	utils.EnableDebugLogForTest()
}
开发者ID:ReinhardHsu,项目名称:platform,代码行数:13,代码来源:apitestlib.go

示例7: configureLog

func configureLog(s *model.LogSettings) {

	l4g.Close()

	if s.EnableConsole {
		level := l4g.DEBUG
		if s.ConsoleLevel == "INFO" {
			level = l4g.INFO
		} else if s.ConsoleLevel == "WARN" {
			level = l4g.WARNING
		} else if s.ConsoleLevel == "ERROR" {
			level = l4g.ERROR
		}

		lw := l4g.NewConsoleLogWriter()
		lw.SetFormat("[%D %T] [%L] %M")
		l4g.AddFilter("stdout", level, lw)
	}

	if s.EnableFile {

		var fileFormat = s.FileFormat

		if fileFormat == "" {
			fileFormat = "[%D %T] [%L] %M"
		}

		level := l4g.DEBUG
		if s.FileLevel == "INFO" {
			level = l4g.INFO
		} else if s.FileLevel == "WARN" {
			level = l4g.WARNING
		} else if s.FileLevel == "ERROR" {
			level = l4g.ERROR
		}

		flw := l4g.NewFileLogWriter(GetLogFileLocation(s.FileLocation), false)
		flw.SetFormat(fileFormat)
		flw.SetRotate(true)
		flw.SetRotateLines(LOG_ROTATE_SIZE)
		l4g.AddFilter("file", level, flw)
	}
}
开发者ID:ttyniwa,项目名称:platform,代码行数:43,代码来源:config.go

示例8: CreateTeam

func (me *TestHelper) CreateTeam() *model.Team {
	id := model.NewId()
	team := &model.Team{
		DisplayName: "dn_" + id,
		Name:        "name" + id,
		Email:       "success+" + id + "@simulator.amazonses.com",
		Type:        model.TEAM_OPEN,
	}

	utils.DisableDebugLogForTest()
	var err *model.AppError
	if team, err = CreateTeam(team); err != nil {
		l4g.Error(err.Error())
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}
	utils.EnableDebugLogForTest()
	return team
}
开发者ID:ZJvandeWeg,项目名称:platform,代码行数:20,代码来源:apptestlib.go

示例9: CreatePost

func (me *TestHelper) CreatePost(channel *model.Channel) *model.Post {
	id := model.NewId()

	post := &model.Post{
		UserId:    me.BasicUser.Id,
		ChannelId: channel.Id,
		Message:   "message_" + id,
	}

	utils.DisableDebugLogForTest()
	var err *model.AppError
	if post, err = CreatePost(post, channel.TeamId, false); err != nil {
		l4g.Error(err.Error())
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}
	utils.EnableDebugLogForTest()
	return post
}
开发者ID:ZJvandeWeg,项目名称:platform,代码行数:20,代码来源:apptestlib.go

示例10: CreateUser

func (me *TestHelper) CreateUser() *model.User {
	id := model.NewId()

	user := &model.User{
		Email:         "success+" + id + "@simulator.amazonses.com",
		Username:      "un_" + id,
		Nickname:      "nn_" + id,
		Password:      "Password1",
		EmailVerified: true,
	}

	utils.DisableDebugLogForTest()
	var err *model.AppError
	if user, err = CreateUser(user); err != nil {
		l4g.Error(err.Error())
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}
	utils.EnableDebugLogForTest()
	return user
}
开发者ID:ZJvandeWeg,项目名称:platform,代码行数:22,代码来源:apptestlib.go

示例11: createChannel

func (me *TestHelper) createChannel(team *model.Team, channelType string) *model.Channel {
	id := model.NewId()

	channel := &model.Channel{
		DisplayName: "dn_" + id,
		Name:        "name_" + id,
		Type:        channelType,
		TeamId:      team.Id,
		CreatorId:   me.BasicUser.Id,
	}

	utils.DisableDebugLogForTest()
	var err *model.AppError
	if channel, err = CreateChannel(channel, true); err != nil {
		l4g.Error(err.Error())
		l4g.Close()
		time.Sleep(time.Second)
		panic(err)
	}
	utils.EnableDebugLogForTest()
	return channel
}
开发者ID:ZJvandeWeg,项目名称:platform,代码行数:22,代码来源:apptestlib.go

示例12: flushLogAndExit

func flushLogAndExit(code int) {
	l4g.Close()
	time.Sleep(time.Second)
	os.Exit(code)
}
开发者ID:cbayleOL,项目名称:platform,代码行数:5,代码来源:mattermost.go

示例13: main

func main() {
	defer logger.Close()
	flag.Parse()
	cpus := runtime.NumCPU()

	logger.Info("CPU核心数=%d,\t并发数=%d,\t单线程请求数=%d,\t每次请求间隔时间=%d,\t请求地址=%s", cpus, *coroutines, *reqnum, *interval, *url)

	timeStart := time.Now().UnixNano()
	runtime.GOMAXPROCS(cpus)

	coroutinesNum := *coroutines
	subCoroutinesNum := *reqnum
	count := coroutinesNum * subCoroutinesNum

	ch := make(chan service.IaxResponse, count)
	defer close(ch)

	for i := 0; i < coroutinesNum; i++ {
		go func(index int) {
			// Start Coroutines
			for j := 0; j < subCoroutinesNum; j++ {
				st := time.Now().UnixNano()
				req := service.IaxRequest{Id: index, SubId: j, Descr: "haha", Url: *url}
				res := Request(req)
				end := time.Now().UnixNano()
				useTimeNano := end - st
				if *interval > 0 && useTimeNano < int64(*interval*1000*1000) {
					sleepTime := int64(*interval*1000*1000) - useTimeNano
					time.Sleep(time.Nanosecond * time.Duration(sleepTime))
				}
				end = time.Now().UnixNano()
				useTime := float64(end-st) / 1000.00 / 1000.00
				res.UseTime = float32(round(useTime, 2))
				ch <- res
			}
		}(i)
	}

	resultList := make([]service.IaxResponse, count)
	next := true
	var index int = 0
	for next {
		select {
		case result := <-ch:
			resultList[index] = result
			index += 1
			if index == count {
				next = false
			}
		}

	}

	timeEnd := time.Now().UnixNano()
	useTime := timeEnd - timeStart

	minUseTime := resultList[0]            // 最小用时
	maxUseTime := minUseTime               // 最大用时
	success := 0                           //成功总数
	successMinUseTime := minUseTime        // 状态成功最小用时
	successMaxUseTime := successMinUseTime // 状态成功最大用时

	successResult := 0
	noAdsCount := 0
	for index, value := range resultList {
		if value.StatusCode == 200 {
			success += 1
			if value.UseTime < successMinUseTime.UseTime {
				successMinUseTime = value
			}
			if value.UseTime > successMaxUseTime.UseTime {
				successMaxUseTime = value
			}
			var result models.Result
			bodyText := value.Body
			bodyText = strings.Replace(bodyText, "window.admaxADMAX_1.serve.callback(", "", -1)
			bodyText = strings.Replace(bodyText, ")", "", -1)
			bodyText = strings.Replace(bodyText, "\n", "", -1)
			bodyText = strings.Replace(bodyText, "\t", "", -1)
			err := json.Unmarshal([]byte(bodyText), &result)
			if err != nil {
				logger.Error("%+v", err)
			}
			value.Result = result
			if result.Success {
				successResult += 1
			}
			if len(result.Ads[0].Link) < 100 || strings.HasPrefix(result.Ads[0].Link, "http") {
				noAdsCount += 1
				logger.Debug(" index=%d use=%.2f-ms\t ----> %s, %s\n", index, value.UseTime, result.Ads[0].BidId, result.Ads[0].Link)
			}

		}
		if value.UseTime < minUseTime.UseTime {
			minUseTime = value
		}
		if value.UseTime > maxUseTime.UseTime {
			maxUseTime = value
		}
		//logger.Info("%d,%+v", index, value)
//.........这里部分代码省略.........
开发者ID:ckex,项目名称:iax-test,代码行数:101,代码来源:main.go

示例14: main

func main() {
	// parse cmd-line arguments
	flag.Parse()
	log.Info("comet ver: \"%s\" start", ver.Version)
	// init config
	if err := InitConfig(); err != nil {
		panic(err)
	}
	// set max routine
	runtime.GOMAXPROCS(Conf.MaxProc)
	// init log
	log.Info("comet log configuration")
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	// start pprof
	log.Info("comet init perf")
	perf.Init(Conf.PprofBind)
	// create channel
	// if process exit, close channel
	UserChannel = NewChannelList()
	defer UserChannel.Close()
	// start stats
	log.Info("comet start stats")

	StartStats()
	// start rpc,应该不需要了吧?
	log.Info("comet start rpc")

	if err := InitControllerRpcClient(); err != nil {
		panic(err)
	}
	defer thriftPool.Release()

	// start comet
	log.Info("comet start ")
	if err := StartComet(); err != nil {
		panic(err)
	}

	// configuration the kafka topic and kafka consumer to consum the notify messages.
	log.Info("queue start")
	if err := StartQueue(); err != nil {
		panic(err)
	}

	// init zookeeper,用来监控instance的启动和服务down。同步instance的ip,queue,信息到配置中心。配置中心监控监控变动,同步信息到调度中心。
	zkConn, err := InitZK()
	if err != nil {
		if zkConn != nil {
			zkConn.Close()
		}
		panic(err)
	}
	// process init
	//	if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
	//		panic(err)
	//	}
	// init signals, block wait signals
	signalCH := InitSignal()
	HandleSignal(signalCH)
	// exit
	log.Info("comet stop")
}
开发者ID:humortian,项目名称:im,代码行数:63,代码来源:main.go


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