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


Golang seelog.Critical函數代碼示例

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


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

示例1: Run

func Run(nsqLookupdHTTPAddrs []string, st store.Store) {

	cfg := nsq.NewConfig()
	cfg.UserAgent = fmt.Sprintf("phosphor go-nsq/%s", nsq.VERSION)
	cfg.MaxInFlight = maxInFlight

	consumer, err := nsq.NewConsumer(topic, channel, cfg)
	if err != nil {
		log.Critical(err)
		os.Exit(1)
	}

	consumer.AddHandler(&IngestionHandler{
		store: st,
	})

	err = consumer.ConnectToNSQLookupds(nsqLookupdHTTPAddrs)
	if err != nil {
		log.Critical(err)
		os.Exit(1)
	}

	// Block until exit
	<-consumer.StopChan
}
開發者ID:gitter-badger,項目名稱:phosphor-1,代碼行數:25,代碼來源:ingester.go

示例2: readFile

func readFile(filename string) int {
	file, err := os.Open(filename)
	if err != nil {
		log.Critical(err)
	}

	count, err = file.Read(buf)
	if err != nil {
		log.Critical(err)
	}

	return count
}
開發者ID:sunbenxin,項目名稱:mycode,代碼行數:13,代碼來源:dsp.go

示例3: main

func main() {
	cluster := gocql.NewCluster("127.0.0.1")
	cluster.Keyspace = "system"
	session, err := cluster.CreateSession()
	defer session.Close()

	if err != nil {
		log.Critical(err)
	}

	traceSession, err := cluster.CreateSession()
	defer session.Close()

	if err != nil {
		log.Critical(err)
	}

	// Create a new logger instance that we adjust the stack depth for to get
	// more meaningful frames
	logger, err := log.LoggerFromConfigAsString(
		`<seelog>
            <outputs>
                <console formatid="fmt"/>
            </outputs>
            <formats>
                <format id="fmt" format="%Date(Jan 02 2006 03:04:05.000) [%LEVEL] %File:%Line - %Msg%n"/>
            </formats>
        </seelog>
        `)
	logger.SetAdditionalStackDepth(2)

	if err != nil {
		log.Critical(err)
	}

	writer := NewTraceWriter(traceSession, logger)
	tracer := gocql.NewTraceWriter(traceSession, writer)
	session.SetTrace(tracer)

	var count int
	iter := session.Query(`select count(*) from schema_keyspaces`).Iter()
	iter.Scan(&count)

	err = iter.Close()

	if err != nil {
		log.Critical(err)
	}

	log.Infof("This instance has %d keyspaces", count)
}
開發者ID:relops,項目名稱:gocql-tracing-example,代碼行數:51,代碼來源:main.go

示例4: doRun

func doRun(opts *Options) {
	defer cleanupLogs()

	// check we have some endpoints
	if reg.size() == 0 {
		log.Critical("There are no endpoints for this service")
		os.Exit(3)
	}

	// start listening for incoming messages
	deliveries, err := raven.Consume(InstanceID)
	if err != nil {
		log.Critical("[Server] Failed to consume: %v", err)
		os.Exit(5)
	}

	if opts.SelfBind {
		// binding should come after you've started consuming
		if err := raven.BindService(Name, InstanceID); err != nil {
			log.Criticalf("[Server] Failed to bind itself: %v", err)
			os.Exit(7)
		}
	}

	// announce ourselves to the discovery service
	dsc = newDiscovery(opts)
	go dsc.connect()

	// run some post connect handlers
	for _, f := range postConnHdlrs {
		go f()
	}

	// register stats collector
	go registerStats()

	// listen for SIGQUIT
	go signalCatcher()

	// consume messages
	for d := range deliveries {
		req := NewRequestFromDelivery(d)
		go HandleRequest(req)
	}

	log.Critical("[Server] Stopping due to channel closing")
	os.Exit(6)
}
開發者ID:armada-io,項目名稱:h2,代碼行數:48,代碼來源:server.go

示例5: runFsInspector

func runFsInspector(args []string) int {
	if err := fsFlagset.Parse(args); err != nil {
		log.Critical(err)
		return 1
	}

	if _fsFlags.OriginalDir == "" {
		log.Critical("original-dir is not set")
		return 1
	}

	if _fsFlags.Mountpoint == "" {
		log.Critical("mount-point is not set")
		return 1
	}

	if _fsFlags.AutopilotConfig != "" && _fsFlags.OrchestratorURL != ocutil.LocalOrchestratorURL {
		log.Critical("non-default orchestrator url set for autopilot orchestration mode")
		return 1
	}

	if logutil.Debug {
		// log level: 0..2
		hookfs.SetLogLevel(1)
	} else {
		hookfs.SetLogLevel(0)
	}

	if _fsFlags.AutopilotConfig != "" {
		cfg, err := config.NewFromFile(_fsFlags.AutopilotConfig)
		if err != nil {
			panic(log.Critical(err))
		}
		autopilotOrchestrator, err := ocutil.NewAutopilotOrchestrator(cfg)
		if err != nil {
			panic(log.Critical(err))
		}
		log.Info("Starting autopilot-mode orchestrator")
		go autopilotOrchestrator.Start()
	}

	hook := &inspector.FilesystemInspector{
		OrchestratorURL: _fsFlags.OrchestratorURL,
		EntityID:        _fsFlags.EntityID,
	}

	fs, err := hookfs.NewHookFs(_fsFlags.OriginalDir, _fsFlags.Mountpoint, hook)
	if err != nil {
		panic(log.Critical(err))
	}
	log.Infof("Serving %s", fs)
	log.Infof("Please run `fusermount -u %s` after using this, manually", _fsFlags.Mountpoint)
	if err = fs.Serve(); err != nil {
		panic(log.Critical(err))
	}
	// NOTREACHED
	return 0
}
開發者ID:terminiter,項目名稱:earthquake,代碼行數:58,代碼來源:fs.go

示例6: Notify

func (emailer *EmailNotifier) Notify(msg Message) error {
	if emailer.auth == nil {
		switch emailer.AuthType {
		case "plain":
			emailer.auth = smtp.PlainAuth("", emailer.Username, emailer.Password, emailer.Server)
		case "crammd5":
			emailer.auth = smtp.CRAMMD5Auth(emailer.Username, emailer.Password)
		}
	}

	if emailer.template == nil {
		template, err := template.ParseFiles(emailer.TemplateFile)
		if err != nil {
			log.Critical("Cannot parse email template: %v", err)
			return err
		}
		emailer.template = template
	}

	if emailer.groupMsgs == nil {
		emailer.groupMsgs = make(map[string]Message)
	}

	for _, group := range emailer.Groups {
		clusterGroup := fmt.Sprintf("%s,%s", msg.Cluster, msg.Group)
		if clusterGroup == group {
			emailer.groupMsgs[clusterGroup] = msg
		}
	}
	if len(emailer.Groups) == len(emailer.groupMsgs) {
		return emailer.sendConsumerGroupStatusNotify()
	}
	return nil
}
開發者ID:Magnetme,項目名稱:Burrow,代碼行數:34,代碼來源:email_notifier.go

示例7: testFuncException

func testFuncException() {
	fmt.Println("testFuncException")
	testConfig := `
<seelog type="sync" minlevel="info">
	<exceptions>
		<exception funcpattern="*main.test*Except*" minlevel="error"/>
	</exceptions>
	<outputs>
		<console/>
	</outputs>
</seelog>`

	logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
	log.ReplaceLogger(logger)

	log.Trace("NOT Printed")
	log.Debug("NOT Printed")
	log.Info("NOT Printed")
	log.Warn("NOT Printed")
	log.Error("Printed")
	log.Critical("Printed")

	log.Current.Trace("NOT Printed")
	log.Current.Debug("NOT Printed")
	log.Current.Info("NOT Printed")
	log.Current.Warn("NOT Printed")
	log.Current.Error("Printed")
	log.Current.Critical("Printed")
}
開發者ID:cihub,項目名稱:seelog-examples,代碼行數:29,代碼來源:exceptions_main.go

示例8: main

func main() {
	// context
	ctx = context.Background()

	loadConfig()

	// db
	hoge.BuildInstances()

	// redis
	redis_pool := newPool()
	ctx = context.WithValue(ctx, "redis", redis_pool)

	router := gin.Default()
	router.Use(Custom())
	// make route
	router.POST("/test", controller.Test)

	err := router.Run(":9999")

	// 存在しないルート時
	if err != nil {
		log.Critical(err)
	}
}
開發者ID:shamoto-donuts,項目名稱:goSample,代碼行數:25,代碼來源:main.go

示例9: QueueNextEvent

func (d *Dumb) QueueNextEvent(event signal.Event) {
	item, err := queue.NewBasicTBQueueItem(event, d.Interval, d.Interval)
	if err != nil {
		panic(log.Critical(err))
	}
	d.queue.Enqueue(item)
}
開發者ID:terminiter,項目名稱:earthquake,代碼行數:7,代碼來源:dumbpolicy.go

示例10: Start

/// 啟動rpcServer,監聽rpc服務器端口,由於Start內部調用阻塞的方法,應在go 語句中調用.
func (ms *RpcServer) Start() {
	go func() {
		seelog.Info("RpcServer start...")
		hostAndPort := fmt.Sprintf("%v:%v", ms.host, ms.port)

		servAddr, err := net.ResolveTCPAddr("tcp", hostAndPort)

		if err != nil {
			seelog.Criticalf("RpcServer failed to start with err<%v>", err.Error())
			os.Exit(1)
		}

		listener, err := net.ListenTCP("tcp4", servAddr)

		if err != nil {
			seelog.Criticalf("RpcServer failed to start with err<%v>", err.Error())
			os.Exit(1)
		}

		seelog.Debugf("Rpc Server listening: <%v>", servAddr.String())
		defer listener.Close()

		for {
			conn, err := listener.Accept()

			seelog.Debug("Rpc Server accept new connection")
			if err != nil {
				seelog.Critical(err.Error())
				os.Exit(1)
			}
			go ms.rpcServer.ServeCodec(jsonrpc.NewServerCodec(conn))
		}
	}()

}
開發者ID:liweisheng,項目名稱:server-framework,代碼行數:36,代碼來源:rpcServer.go

示例11: Default

func Default() *truetype.Font {

	if defaultFont == nil {
		fontBytes, err := ioutil.ReadFile("test.ttf")
		if err != nil {
			log.Critical(err)
			return nil
		}
		defaultFont, err = freetype.ParseFont(fontBytes)
		if err != nil {
			log.Critical(err)
			return nil
		}
	}

	return defaultFont
}
開發者ID:romovs,項目名稱:viscum,代碼行數:17,代碼來源:fonts.go

示例12: Critical

// Critical outputs critical level message.
func Critical(msg ...interface{}) {
	if !isValid {
		return
	}
	mutex.Lock()
	defer mutex.Unlock()
	seelog.Critical(msg...)
}
開發者ID:unirita,項目名稱:gocutoweb,代碼行數:9,代碼來源:log.go

示例13: loadImage

func loadImage(filename string) (image.Image, error) {

	f, err := os.Open(filename)
	if err != nil {
		log.Critical(err)
		return nil, err
	}
	defer f.Close()

	img, _, err := image.Decode(bufio.NewReader(f))
	if err != nil {
		log.Critical(err)
		return nil, err
	}

	return img, nil
}
開發者ID:romovs,項目名稱:viscum,代碼行數:17,代碼來源:toolkit.go

示例14: Critical

// criticalレベルでログメッセージを出力する。
// この関數が呼び出されると、ただちにログのフラッシュが行われる。
//
// param : msg 出力するメッセージ。複數指定した場合は結合して出力される。
func Critical(msg ...interface{}) {
	if !valid {
		return
	}
	locker.Lock(lockTimeout)
	defer locker.Unlock()
	seelog.Critical(msg...)
}
開發者ID:unikk,項目名稱:cuto,代碼行數:12,代碼來源:log.go

示例15: StartEarthquakeRoutines

func StartEarthquakeRoutines(c *docker.Container, cfg config.Config) error {
	log.Debugf("Starting Orchestrator")
	go func() {
		oerr := StartOrchestrator(cfg)
		if oerr != nil {
			panic(log.Critical(oerr))
		}
	}()

	if cfg.GetBool("containerParam.enableEthernetInspector") {
		nfqNum := cfg.GetInt("containerParam.ethernetNFQNumber")
		if nfqNum <= 0 {
			return fmt.Errorf("strange containerParam.ethernetNFQNumber: %d", nfqNum)
		}
		log.Debugf("Configuring NFQUEUE %d for container %s", nfqNum, c.ID)
		err := SetupNFQUEUE(c, nfqNum, false, false)
		if err != nil {
			return err
		}
		log.Debugf("Starting Ethernet Inspector")
		go func() {
			ierr := StartEthernetInspector(c, nfqNum)
			if ierr != nil {
				panic(log.Critical(ierr))
			}
		}()
	}

	if cfg.GetBool("containerParam.enableProcInspector") {
		watchInterval := cfg.GetDuration("containerParam.procWatchInterval")
		if watchInterval <= 0 {
			return fmt.Errorf("strange containerParam.procWatchInterval: %s", watchInterval)
		}
		log.Debugf("Starting Process Inspector")
		go func() {
			ierr := StartProcInspector(c, watchInterval)
			if ierr != nil {
				panic(log.Critical(ierr))
			}
		}()
	}

	return nil
}
開發者ID:terminiter,項目名稱:earthquake,代碼行數:44,代碼來源:start.go


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