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


Golang log4go.Close函数代码示例

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


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


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