• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log4go.Close函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	log.Global = log.NewDefaultLogger(log.DEBUG)
	flag.Parse()
	defer log.Close()
	begin, err := strconv.Atoi(os.Args[1])
	if err != nil {
		panic(err)
	}

	num, err := strconv.Atoi(os.Args[2])
	if err != nil {
		panic(err)
	}

	go result()

	for i := begin; i < begin+num; i++ {
		key := fmt.Sprintf("%d", i)
		quit := make(chan bool, 1)
		go startClient(key, quit)
	}

	var exit chan bool
	<-exit
}
开发者ID:dulumao,项目名称:goim,代码行数:26,代码来源:main.go


示例2: main

func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("logic[%s] start", Ver)
	perf.Init(Conf.PprofAddrs)
	// router rpc
	if err := InitRouter(); err != nil {
		log.Warn("router rpc current can't connect, retry")
	}
	MergeRoomCount()
	go SyncRoomCount()
	// logic rpc
	if err := InitRPC(NewDefaultAuther()); err != nil {
		panic(err)
	}
	if err := InitKafka(Conf.KafkaAddrs); err != nil {
		panic(err)
	}
	if err := InitHTTP(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
开发者ID:james4e,项目名称:goim,代码行数:29,代码来源:main.go


示例3: main

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	log.Global = log.NewDefaultLogger(log.DEBUG)
	flag.Parse()
	defer log.Close()
	begin, err := strconv.Atoi(os.Args[1])
	if err != nil {
		panic(err)
	}

	num, err := strconv.Atoi(os.Args[2])
	if err != nil {
		panic(err)
	}

	//time.AfterFunc(time.Duration(t)*time.Second, stop)
	go result()

	for i := begin; i < begin+num; i++ {
		key := fmt.Sprintf("%d", i)
		go startClient(key)
	}

	var exit chan bool
	<-exit
}
开发者ID:nevermatch,项目名称:goim,代码行数:26,代码来源:main.go


示例4: 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:xuguangtech,项目名称:gopush-cluster,代码行数:34,代码来源:main.go


示例5: main

func main() {

	runtime.GOMAXPROCS(runtime.NumCPU())
	//l4g.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter("server.log", false))
	// creates a tcp listener
	l4g.LoadConfiguration("./conf/log4go.xml")
	tcpAddr, err := net.ResolveTCPAddr("tcp4", ":8989")
	checkError(err)
	listener, err := net.ListenTCP("tcp", tcpAddr)
	checkError(err)
	defer l4g.Close()
	// creates a server
	config := &gotcp.Config{
		PacketSendChanLimit:    20,
		PacketReceiveChanLimit: 20,
	}
	srv := gotcp.NewServer(config, &Callback{}, &echo.EchoProtocol{})

	// starts service
	go srv.Start(listener, time.Second)
	l4g.Debug("listening: %s", listener.Addr())
	//log.Println("listening:", listener.Addr())

	// catchs system signal
	chSig := make(chan os.Signal)
	signal.Notify(chSig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR2) //, syscall.SIGINT, syscall.SIGTERM
	l4g.Trace("Signal: %s", <-chSig)
	//log.Println("Signal: ", <-chSig)

	// stops service
	srv.Stop()
}
开发者ID:whiskerman,项目名称:gotcp,代码行数:32,代码来源:server.go


示例6: main

func main() {
	var (
		addr     *net.UDPAddr
		listener *net.UDPConn
		err      error
	)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	if addr, err = net.ResolveUDPAddr("udp4", Conf.Bind); err != nil {
		log.Error("net.ResolveUDPAddr(\"udp4\", \"%s\") error(%v)", Conf.Bind, err)
		return
	}

	if listener, err = net.ListenUDP("udp4", addr); err != nil {
		log.Error("net.ListenUDP(\"udp4\", \"%v\") error(%v)", addr, err)
		return
	}
	defer listener.Close()

	if Debug {
		log.Debug("start udp listen: \"%s\"", Conf.Bind)
	}

	//N core accept
	for i := 0; i < Conf.MaxProc; i++ {
		go acceptUDP(listener)
	}
	//wait
	InitSignal()
}
开发者ID:it-man-cn,项目名称:go-acs,代码行数:30,代码来源:main.go


示例7: Must

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

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


示例8: 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:neozhangthe1,项目名称:platform,代码行数:10,代码来源:store.go


示例9: main

func main() {
	// init cmd args
	flag.Parse()
	// init config
	if err := initConfig(); err != nil {
		os.Exit(termExit)
	}
	// init log
	log.LoadConfiguration(conf.Log)
	defer log.Close()
	if len(conf.Sentinel) == 0 {
		// set to zk
		log.Error("conf.Sentinel don't have any sentinel addr")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	log.Info("sentinels: \"%v\", master: \"%s\"", conf.Sentinel, conf.Master)
	// init sentinel addrs
	for _, addr := range conf.Sentinel {
		sentinelList.PushBack(addr)
	}
	redisConn := sentinel()
	if redisConn == nil {
		log.Error("sentinel can't connect")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	defer redisConn.Close()
	// master redis
	redisMaster := masterAddr(redisConn)
	log.Debug("redis master: \"%s\"", redisMaster)
	isMaster := checkRole(redisMaster, roleMaster)
	if isMaster {
		refreshSentinel(redisConn)
	} else {
		log.Warn("abort the mission, master not ok")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	// set to zk
	zkConn := zkDial()
	if zkConn == nil {
		log.Error("zookeeper can't connect")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	defer zkConn.Close()
	if err := zkData(zkConn, redisMaster); err != nil {
		log.Error("zookeeper set data failed")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	time.Sleep(logWait)
	os.Exit(okExit)
}
开发者ID:felixhao,项目名称:goredis-failover,代码行数:55,代码来源:main.go


示例10: main

func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	if Conf.Type == ProtoTCP {
		initTCP()
	} else if Conf.Type == ProtoWebsocket {
		initWebsocket()
	} else if Conf.Type == ProtoWebsocketTLS {
		initWebsocketTLS()
	}
}
开发者ID:dulumao,项目名称:goim,代码行数:16,代码来源:main.go


示例11: main

func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	perf.Init(Conf.PprofBind)
	if Conf.Type == ProtoTCP {
		initTCP()
	} else if Conf.Type == ProtoWebsocket {
		initWebsocket()
	}
	time.Sleep(10 * time.Second)
}
开发者ID:nevermatch,项目名称:goim,代码行数:16,代码来源:main.go


示例12: 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.LoadConfiguration(Conf.Log)
	defer log.Close()
	// start pprof
	perf.Init(Conf.PprofBind)
	// create channel
	// if process exit, close channel
	UserChannel = NewChannelList()
	defer UserChannel.Close()
	// start stats
	StartStats()
	// start rpc
	if err := StartRPC(); err != nil {
		panic(err)
	}
	// start comet
	if err := StartComet(); err != nil {
		panic(err)
	}
	// init zookeeper
	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:RobotJiang,项目名称:gopush-cluster,代码行数:47,代码来源:main.go


示例13: main

func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("comet[%s] start", Ver)
	perf.Init(Conf.PprofBind)
	// logic rpc
	if err := InitLogicRpc(Conf.LogicAddr); err != nil {
		log.Warn("logic rpc current can't connect, retry")
	}
	// new server
	buckets := make([]*Bucket, Conf.Bucket)
	for i := 0; i < Conf.Bucket; i++ {
		buckets[i] = NewBucket(Conf.Channel, Conf.Room, Conf.RoomChannel, Conf.CliProto, Conf.SvrProto)
	}
	round := NewRound(Conf.ReadBuf, Conf.WriteBuf, Conf.Timer, Conf.TimerSize)
	operator := new(DefaultOperator)
	DefaultServer = NewServer(buckets, round, operator)
	if err := InitTCP(); err != nil {
		panic(err)
	}
	if err := InitWebsocket(); err != nil {
		panic(err)
	}
	if Conf.WebsocketTLSOpen {
		if err := InitWebsocketWithTLS(); err != nil {
			panic(err)
		}
	}
	if err := InitHTTP(); err != nil {
		panic(err)
	}
	// start rpc
	if err := InitRPCPush(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
开发者ID:hudangwei,项目名称:goim,代码行数:43,代码来源:main.go


示例14: main

func main() {

	flag.Parse()
	if err := InitConfig(); err != nil {
		fmt.Printf("init err: %s", err)
		panic(err)
	}

	log.LoadConfiguration(Conf.Log)
	defer log.Close()

	// init evnet and shutdown
	InitEvent()
	defer ShutdownEvent()

	SyncDaemon()

	signal.InitSignal(reload)
}
开发者ID:hushi55,项目名称:Grep,代码行数:19,代码来源:main.go


示例15: 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
		}

		l4g.AddFilter("stdout", level, l4g.NewConsoleLogWriter())
	}

	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:mf1389004071,项目名称:platform,代码行数:41,代码来源:config.go


示例16: main

func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("comet[%s] start", Ver)
	perf.Init(Conf.PprofBind)
	if err := InitRSA(); err != nil {
		panic(err)
	}
	// new server
	buckets := make([]*Bucket, Conf.Bucket)
	for i := 0; i < Conf.Bucket; i++ {
		buckets[i] = NewBucket(Conf.Channel, Conf.CliProto, Conf.SvrProto)
	}
	round := NewRound(Conf.ReadBuf, Conf.WriteBuf, Conf.Timer, Conf.TimerSize, Conf.Session, Conf.SessionSize)
	codec := new(BinaryServerCodec)
	operator := new(DefaultOperator)
	cryptor := NewDefaultCryptor()
	DefaultServer = NewServer(buckets, round, codec, operator, cryptor)
	if err := InitTCP(); err != nil {
		panic(err)
	}
	if err := InitWebsocket(); err != nil {
		panic(err)
	}
	if err := InitHttpPush(); err != nil {
		panic(err)
	}
	// start rpc
	if err := InitRPCPush(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
开发者ID:zhoudianyou,项目名称:goim,代码行数:39,代码来源:main.go


示例17: main

func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("router[%s] start", VERSION)
	// start prof
	perf.Init(Conf.PprofBind)
	// start rpc
	buckets := make([]*Bucket, Conf.Bucket)
	for i := 0; i < Conf.Bucket; i++ {
		buckets[i] = NewBucket(Conf.Session, Conf.Server, Conf.Cleaner)
	}
	if err := InitRPC(buckets); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
开发者ID:sf100,项目名称:goim,代码行数:22,代码来源:main.go


示例18: configureLog

func configureLog(s LogSettings) {

	l4g.Close()

	if s.ConsoleEnable {
		level := l4g.DEBUG
		if s.ConsoleLevel == "INFO" {
			level = l4g.INFO
		} else if s.ConsoleLevel == "ERROR" {
			level = l4g.ERROR
		}

		l4g.AddFilter("stdout", level, l4g.NewConsoleLogWriter())
	}

	if s.FileEnable {
		if s.FileFormat == "" {
			s.FileFormat = "[%D %T] [%L] %M"
		}

		if s.FileLocation == "" {
			s.FileLocation = FindDir("logs") + "mattermost.log"
		}

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

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


示例19: init

func init() {
	log4go.Close()
	log4go.AddFilter("test", log4go.DEBUG, log4go.NewConsoleLogWriter())
}
开发者ID:ksurdy,项目名称:completion,代码行数:4,代码来源:net_test.go


示例20: flushLogAndExit

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log4go.Critical函数代码示例发布时间:2022-05-24
下一篇:
Golang log4go.AddFilter函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap