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


Golang seelog.LoggerFromConfigAsFile函數代碼示例

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


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

示例1: main

func main() {
	logConfigFile := flag.String("l", "./conf/log.xml", "Log config file")
	configFile := flag.String("c", "./conf/conf.json", "Config file")

	flag.Parse()

	logger, err := log.LoggerFromConfigAsFile(*logConfigFile)
	if err != nil {
		fmt.Printf("Load log config failed: (%s)\n", err)
		os.Exit(1)
	}

	log.ReplaceLogger(logger)

	err = conf.LoadConfig(*configFile)
	if err != nil {
		log.Warnf("LoadConfig (%s) failed: (%s)\n", *configFile, err)
		os.Exit(1)
	}

	http.HandleFunc("/api/v1/notify", postNotify)
	err = http.ListenAndServe(conf.Config.Notify.Addr, nil)
	if err != nil {
		log.Warnf("failed to ListenAndServe: ", err)
		os.Exit(1)
	}
}
開發者ID:houcy,項目名稱:push,代碼行數:27,代碼來源:notify.go

示例2: initAppConfig

func initAppConfig() {
	logger, err := seelog.LoggerFromConfigAsFile("./config/log.xml")
	if err != nil {
		log.Fatalln(err)
	}
	Logger = logger
}
開發者ID:ZHGDG,項目名稱:flute,代碼行數:7,代碼來源:log.go

示例3: main

func main() {
	//err := LoadConfig("/system/etc/conf.json")
	err := LoadConfig("./conf.json")
	if err != nil {
		fmt.Printf("LoadConfig failed: (%s)", err)
		os.Exit(1)
	}

	//logger, err := log.LoggerFromConfigAsFile("/system/etc/log.xml")
	logger, err := log.LoggerFromConfigAsFile("./log.xml")
	if err != nil {
		fmt.Printf("Load log config failed: (%s)\n", err)
		os.Exit(1)
	}
	log.ReplaceLogger(logger)

	//wg := &sync.WaitGroup{}
	agent := NewAgent()
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)

	wg := sync.WaitGroup{}
	wg.Add(1)
	go func() {
		agent.Run()
		log.Infof("agent quited")
		wg.Done()
	}()
	sig := <-c
	log.Infof("Received signal '%v', exiting\n", sig)
	agent.Stop()
	wg.Wait()
}
開發者ID:chenyf,項目名稱:gibbon,代碼行數:33,代碼來源:gibbonagent.go

示例4: InitLogger

func InitLogger(configFile string) {
	fmt.Fprintln(os.Stderr, "Use "+configFile+" init Logger")
	m.Lock()
	defer m.Unlock()

	if loggerInitd {
		Errorf("Logger has been already inited.")
		return
	}

	seelogger, err := seelog.LoggerFromConfigAsFile(configFile)

	if err != nil {
		log.Panicf("Can't init Logger,error:%s", err)
		return
	} else {
		//確保取得正確的調用堆棧
		seelogger.SetAdditionalStackDepth(2)
	}

	realLogger := logger.(*SeeLogLogger)
	if realLogger.seelogger != nil {
		realLogger.seelogger.Flush()
		realLogger.seelogger.Close()
	}
	realLogger.seelogger = seelogger
	loggerInitd = true
}
開發者ID:d0ngw,項目名稱:go,代碼行數:28,代碼來源:logger.go

示例5: init

func init() {
	logger, err := log.LoggerFromConfigAsFile("seelog.xml")
	if err != nil {
		panic(err)
	}
	log.ReplaceLogger(logger)
}
開發者ID:relops,項目名稱:gocql-tracing-example,代碼行數:7,代碼來源:main.go

示例6: InitSeeLog

func InitSeeLog(seeLogCfgFile string) {
	logger, err := log.LoggerFromConfigAsFile(seeLogCfgFile)
	if err != nil {
		log.Errorf("Parse seelog config file error: %s", err.Error)
		os.Exit(1)
	}
	log.ReplaceLogger(logger)
}
開發者ID:idlecloud,項目名稱:redishazk,代碼行數:8,代碼來源:redis_ha.go

示例7: SeelogConfig

func SeelogConfig() seelog.LoggerInterface {
	logger, err := seelog.LoggerFromConfigAsFile("seelog_config.xml")
	if err != nil {
		fmt.Println(err)
		return nil
	}
	return logger
}
開發者ID:adtechtest,項目名稱:prog_buy,代碼行數:8,代碼來源:settings.go

示例8: LoadConf

func LoadConf(configPath string) {
	DisableLog()
	logger, err := seelog.LoggerFromConfigAsFile(configPath)
	if err != nil {
		panic(err)
	}
	UseLogger(logger)
}
開發者ID:ohlinux,項目名稱:golang-snippet-cn,代碼行數:8,代碼來源:logging.go

示例9: InitLogger

func InitLogger(configPath string) {
	logger, err := seelog.LoggerFromConfigAsFile(configPath)
	if err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
	seelog.ReplaceLogger(logger)
}
開發者ID:Everley1993,項目名稱:TimerNotificationService,代碼行數:8,代碼來源:main.go

示例10: loadAppConfig

func loadAppConfig() {
	logger, err := seelog.LoggerFromConfigAsFile("./seelog.xml")
	if err != nil {
		fmt.Println(err)
		return
	}
	UseLogger(logger)
}
開發者ID:jango2015,項目名稱:ngw,代碼行數:8,代碼來源:logs.go

示例11: updateLogger

func updateLogger() error {
	logger, err := log.LoggerFromConfigAsFile(LOGGER_CONFIG)
	if err != nil {
		return err
	}

	return log.ReplaceLogger(logger)
}
開發者ID:ohhdemgirls,項目名稱:trantor,代碼行數:8,代碼來源:trantor.go

示例12: main

func main() {
	defer log.Flush()
	logger, err := log.LoggerFromConfigAsFile("seelog.xml")

	if nil != err {
		log.Warn("Failed to load config", err)
	}
	log.ReplaceLogger(logger)
	flag.Parse()
	statsTransformChannel := make(chan *diskStat.DiskStat, 10)
	statsOutputChannel := make(chan *diskStat.ExtendedIoStats, 10)

	var output outputInterface.Output
	proto := PStdOut

	switch *protocolType {
	case "protobuffers":
		{
			proto = PProtoBuffers
		}
	case "json":
		{
			proto = PJson
		}
	default:
		{
			if *outputType == "zmq" {
				proto = PProtoBuffers
			} else if *outputType == "stdout" {
				proto = PStdOut
			}
		}
	}

	switch *outputType {
	case "zmq":
		output, err = zmqOutput.NewZmqOutput(queueUrl, proto)
	case "nano":
		output, err = nanoMsgOutput.NewNanoMsgOutput(queueUrl, proto)
	default:
		output = &logOutput.LogOutput{proto}
	}
	if nil != err {
		log.Error("Failed to setup output ", err)
	}

	go ioStatTransform.TransformStat(statsTransformChannel, statsOutputChannel)

	go statsOutput.Output(statsOutputChannel, output)

	for {
		readAndSendStats(statsTransformChannel)
		time.Sleep(time.Second * time.Duration(*interval))

	}
	close(statsTransformChannel)
	close(statsOutputChannel)
}
開發者ID:lucmichalski,項目名稱:goiostat,代碼行數:58,代碼來源:goiostat.go

示例13: main

func main() {
	cfgfile := "conf.json"
	begin := 0
	count := 1
	if len(os.Args) >= 3 {
		begin, _ = strconv.Atoi(os.Args[1])
		count, _ = strconv.Atoi(os.Args[2])
	}
	r, err := os.Open(cfgfile)
	if err != nil {
		fmt.Printf("failed to open config file %s", cfgfile)
		os.Exit(1)
	}

	var config Config
	decoder := json.NewDecoder(r)
	err = decoder.Decode(&config)
	if err != nil {
		fmt.Printf("invalid config file")
		os.Exit(1)
	}
	if config.ReadTimeout <= 0 {
		config.ReadTimeout = time.Duration(20)
	}

	logger, err := log.LoggerFromConfigAsFile("log.xml")
	if err != nil {
		fmt.Printf("Load log config failed: (%s)\n", err)
		os.Exit(1)
	}
	log.ReplaceLogger(logger)

	server, _ := net.ResolveTCPAddr("tcp4", config.Server)
	wg := &sync.WaitGroup{}
	c := make(chan os.Signal, 1)
	ctrl := make(chan bool, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)

	running := true
	wg.Add(1)
	go func() {
		sig := <-c
		log.Infof("Received signal '%v', exiting\n", sig)
		running = false
		close(ctrl)
		wg.Done()
	}()

	for n := begin; n < begin+count; n++ {
		if !running {
			break
		}
		go runClient(n, &config, wg, ctrl, nil, server)
		time.Sleep(config.Interval * time.Millisecond)
	}
	wg.Wait()
}
開發者ID:houcy,項目名稱:push,代碼行數:57,代碼來源:pushtest.go

示例14: NewLogger

func NewLogger(cfgfile string) *BurrowLogger {
	logger, err := log.LoggerFromConfigAsFile(cfgfile)
	if err != nil {
		log.Criticalf("Cannot start logger: %v", err)
		os.Exit(1)
	}
	log.ReplaceLogger(logger)
	return &BurrowLogger{logger}
}
開發者ID:Chandra-TechPassionate,項目名稱:Burrow,代碼行數:9,代碼來源:logger.go

示例15: log_init

func log_init() {
	defer log.Flush()
	logger, e := log.LoggerFromConfigAsFile(GetConfigDir() + "/log.conf")
	if e != nil {
		log.Criticalf("Error %v", e)
	}
	log.ReplaceLogger(logger)
	//TODO timer watch config file
}
開發者ID:sichuanyl,項目名稱:babylon,代碼行數:9,代碼來源:config.go


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