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


Golang Logger.Info函数代码示例

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


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

示例1: handleEvent

// handleEvents takes each type of event to its corresponding callback.
// A full list of events can be found in the source code: https://goo.gl/ESCO4K.
func (q *Qubot) handleEvent(event *slack.RTMEvent) error {
	switch e := event.Data.(type) {
	case *slack.ConnectingEvent:
		logger.Debug("qubot", "Connection attempt", "count", e.Attempt)
	case *slack.ConnectedEvent:
		logger.Info("qubot", "Connected to Slack!")
		return q.onConnectedEvent(e)
	case *slack.HelloEvent:
		logger.Info("qubot", "Slack sent greetings!")
	case *slack.LatencyReport:
		logger.Debug("qubot", "Latency report", "duration", e.Value)
	case *slack.MessageEvent:
		logger.Debug("qubot", "Message received")
		return q.onMessageEvent(e)
	case *slack.InvalidAuthEvent:
		panic("Unrecoverable error: InvalidAuthEvent")
	case *slack.RTMError:
	case *slack.AckErrorEvent:
	case *slack.ConnectionErrorEvent:
	case *slack.DisconnectedEvent:
	case *slack.MessageTooLongEvent:
	case *slack.OutgoingErrorEvent:
	default:
		logger.Debug("qubot", "Unknown event received", "type", event.Type)
	}
	return nil
}
开发者ID:sevein,项目名称:qubot,代码行数:29,代码来源:qubot.go

示例2: sendCoroutine

func sendCoroutine(client *Client) {
	for {
		if !client.running {
			return
		}

		select {
		case <-client.chStop:
			Logger.Info(LogConf.NetCoreClient, client.idx, "sendCoroutine exit.")
			return
		case buf := <-client.sendQ:
			if err := (*client.conn).SetWriteDeadline(time.Now().Add(NetConf.WRITE_BLOCK_TIME)); err != nil {
				client.Stop()
				Logger.Info(LogConf.NetCoreClient, client.idx, "SetWriteDeadline error: %v", err)
			}
			writeLen, err := client.conn.Write(buf)
			if err != nil || writeLen != len(buf) {
				client.Stop()
				Logger.Info(LogConf.NetCoreClient, client.idx, "Write error, len: %d error: %v", writeLen, buf)
			} else {
				//Logger.Info(LogConf.NetCoreClient, client.idx, "Write %v", buf)
			}

		}
	}
}
开发者ID:cokeboL,项目名称:GoWorld,代码行数:26,代码来源:Client.go

示例3: handleClientLeaveRoom

func handleClientLeaveRoom(client *NetCore.Client, msg *NetCore.NetMsg) bool {
	client.RemoveCloseCB("leaveRoom")

	msg.Buf = ErrConf.GetEmptyRspBuffer(ErrConf.NO_ERR)
	client.SendMsg(msg)

	if room, ok := idRoomMap[client.Id]; ok {
		Logger.Info(LogConf.WorkerClientJob, client.Idx, "client leave room id: %d RoomId: %d", client.Id, room.Id)

		notify := &LeaveRoomNotify{
			Id: NetCore.ClientIDType(client.Id),
		}
		msg.Cmd = MsgConf.ClientLeaveRoomNotify
		if buf, err := json.Marshal(notify); err == nil {
			msg.Buf = buf
		} else {
			return false
		}

		delete(room.Guests, client.Id)

		if len(room.Guests) > 0 {
			for _, v := range room.Guests {
				v.SendMsg(msg)
			}
		} else {
			delete(rooms, room.Id)
		}
	}

	Logger.Info(LogConf.WorkerClientJob, client.Idx, "handleClientLeaveRoom client Idx: %d id: %d", client.Idx, client.Id)

	return true
}
开发者ID:cokeboL,项目名称:ZIM,代码行数:34,代码来源:Room.go

示例4: resolveTask

func (handler *Handler) resolveTask(task *models.Task) {
	err := handler.bbs.ResolvingTask(task)
	if err != nil {
		logger.Info("handler.resolving-failed", map[string]interface{}{
			"task":  task.Guid,
			"error": err.Error(),
		})

		return
	}

	err = handler.natsClient.Publish(task.ReplyTo, task.ToJSON())
	if err != nil {
		logger.Error("handler.publish-failed", map[string]interface{}{
			"task":  task.Guid,
			"error": err.Error(),
		})

		return
	}

	err = handler.bbs.ResolveTask(task)
	if err != nil {
		logger.Error("handler.resolve-failed", map[string]interface{}{
			"task":  task.Guid,
			"error": err.Error(),
		})

		return
	}

	logger.Info("handler.resolved", map[string]interface{}{
		"task": task.Guid,
	})
}
开发者ID:vito,项目名称:fake-diego-release,代码行数:35,代码来源:handler.go

示例5: readCoroutine

func readCoroutine(client *Client) {
	defer Commen.HandlePanic()

	head := make([]byte, PACK_HEAD_LEN)
	var readLen = 0
	var err error

	for {
		if !client.running {
			goto Exit
		}

		if err = (*client.conn).SetReadDeadline(time.Now().Add(NetConf.READ_BLOCK_TIME)); err != nil {
			//Logger.Info(LogConf.NetCoreClient, client.Idx, "SetReadDeadline error: %v", err)
			goto Exit
		}

		lastRead := time.Now().UTC()
		readLen, err = io.ReadFull(client.conn, head)
		if err != nil || readLen < PACK_HEAD_LEN {
			Logger.Info(LogConf.NetCoreClient, client.Idx, "Read head error: %v %v %v", err, lastRead, time.Now().UTC())
			goto Exit
		}

		if err = (*client.conn).SetReadDeadline(time.Now().Add(NetConf.READ_BLOCK_TIME)); err != nil {
			Logger.Info(LogConf.NetCoreClient, client.Idx, "SetReadDeadline error: %v", err)
			goto Exit
		}

		var msg = new(NetMsg)
		//var msg = &NetMsg{}

		msg.BufLen = binary.LittleEndian.Uint32(head[0:4])
		msg.Cmd = binary.LittleEndian.Uint32(head[4:8])
		//msg.action = binary.LittleEndian.Uint16(head[6:8])

		if msg.BufLen > 0 {
			msg.Buf = make([]byte, msg.BufLen)
			readLen, err := io.ReadFull(client.conn, msg.Buf)
			if err != nil || readLen != int(msg.BufLen) {
				Logger.Info(LogConf.NetCoreClient, client.Idx, "Read body error: %v", err)
				goto Exit
			}
		}
		//Logger.Info(LogConf.NetCoreClient, client.Idx, "msg read ---->>> : %d %d %v", msg.Cmd, msg.BufLen, msg.Buf)

		if ENABLE_MSG_COROUTINE {
			client.recvQ <- msg
		} else {
			client.HandleMsg(msg)
		}

	}

Exit:
	client.Stop()
	Logger.Info(LogConf.NetCoreClient, client.Idx, "%d readCoroutine exit.", client.Idx)
	return
}
开发者ID:cokeboL,项目名称:ZIM,代码行数:59,代码来源:Client.go

示例6: CancelWaitRegist

func (client *Client) CancelWaitRegist() {
	Logger.Info(LogConf.NetCoreClient, client.Idx, "CancelWaitRegist, client Idx: %d  111", client.Idx)
	key := fmt.Sprintf("WaitRegist_%d", client.Idx)
	if _, ok := clientValidTimerMap[key]; ok {
		delete(clientValidTimerMap, key)
	}
	Logger.Info(LogConf.NetCoreClient, client.Idx, "CancelWaitRegist, client Idx: %d  222", client.Idx)
}
开发者ID:ccppluagopy,项目名称:Zebra,代码行数:8,代码来源:Client.go

示例7: main

func main() {
	// Metron is intended to be light-weight so we occupy only one core
	runtime.GOMAXPROCS(1)

	flag.Parse()
	config, err := config.ParseConfig(*configFilePath)
	if err != nil {
		panic(fmt.Errorf("Unable to parse config: %s", err))
	}

	logger := logger.NewLogger(*debug, *logFilePath, "metron", config.Syslog)

	statsStopChan := make(chan struct{})
	batcher, eventWriter := initializeMetrics(config, statsStopChan, logger)

	go func() {
		err := http.ListenAndServe(net.JoinHostPort("localhost", pprofPort), nil)
		if err != nil {
			logger.Errorf("Error starting pprof server: %s", err.Error())
		}
	}()

	logger.Info("Startup: Setting up the Metron agent")
	marshaller, err := initializeDopplerPool(config, batcher, logger)
	if err != nil {
		panic(fmt.Errorf("Could not initialize doppler connection pool: %s", err))
	}

	messageTagger := tagger.New(config.Deployment, config.Job, config.Index, marshaller)
	aggregator := messageaggregator.New(messageTagger, logger)
	eventWriter.SetWriter(aggregator)

	dropsondeUnmarshaller := eventunmarshaller.New(aggregator, batcher, logger)
	metronAddress := fmt.Sprintf("127.0.0.1:%d", config.IncomingUDPPort)
	dropsondeReader, err := networkreader.New(metronAddress, "dropsondeAgentListener", dropsondeUnmarshaller, logger)
	if err != nil {
		panic(fmt.Errorf("Failed to listen on %s: %s", metronAddress, err))
	}

	logger.Info("metron started")
	go dropsondeReader.Start()

	dumpChan := signalmanager.RegisterGoRoutineDumpSignalChannel()
	killChan := signalmanager.RegisterKillSignalChannel()

	for {
		select {
		case <-dumpChan:
			signalmanager.DumpGoRoutine()
		case <-killChan:
			logger.Info("Shutting down")
			close(statsStopChan)
			return
		}
	}
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:56,代码来源:main.go

示例8: handleHeartBeat

func handleHeartBeat(client *Client, msg *NetMsg) bool {
	if client.stype == NetConf.Client {
		Logger.Info(LogConf.NetCoreCommen, client.Idx, "handle Client HeartBeat client Idx: %d", client.Idx)
		client.SendMsg(msg)
	} else {
		Logger.Info(LogConf.NetCoreCommen, client.Idx, "handle Server HeartBeat client Idx: %d", client.Idx)
		msg.Cmd = MsgConf.HeartBeat2
		client.SendMsg(msg)
	}
	return true
}
开发者ID:cokeboL,项目名称:ZIM,代码行数:11,代码来源:Commen.go

示例9: readCoroutine

func readCoroutine(client *Client) {
	head := make([]byte, PACK_HEAD_LEN)
	var readLen = 0
	var err error

	for {
		if !client.running {
			goto Exit
		}

		if err = (*client.conn).SetReadDeadline(time.Now().Add(NetConf.READ_BLOCK_TIME)); err != nil {
			Logger.Info(LogConf.NetCoreClient, client.idx, "SetReadDeadline error: %v", err)
			goto Exit
			return
		}

		readLen, err = io.ReadFull(client.conn, head)
		if err != nil || readLen < PACK_HEAD_LEN {
			Logger.Info(LogConf.NetCoreClient, client.idx, "Read head error: %v", err)
			goto Exit
			return
		}

		if err = (*client.conn).SetReadDeadline(time.Now().Add(NetConf.READ_BLOCK_TIME)); err != nil {
			Logger.Info(LogConf.NetCoreClient, client.idx, "SetReadDeadline error: %v", err)
			goto Exit
			return
		}

		//var msg = new(NetMsg)
		var msg = &NetMsg{}

		msg.BufLen = binary.LittleEndian.Uint32(head[0:4])
		msg.Cmd = binary.LittleEndian.Uint32(head[4:8])
		//msg.action = binary.LittleEndian.Uint16(head[6:8])

		if msg.BufLen > 0 {
			msg.Buf = make([]byte, msg.BufLen)
			readLen, err := io.ReadFull(client.conn, msg.Buf)
			if err != nil || readLen != int(msg.BufLen) {
				Logger.Info(LogConf.NetCoreClient, client.idx, "Read body error: %v", err)
				goto Exit
				return
			}
		}

		client.recvQ <- msg
	}

Exit:
	client.Stop()
	Logger.Info(LogConf.NetCoreClient, client.idx, "readCoroutine exit.")
	return
}
开发者ID:cokeboL,项目名称:GoWorld,代码行数:54,代码来源:Client.go

示例10: WaitRegist

func (client *Client) WaitRegist() {
	Logger.Info(LogConf.NetCoreClient, client.Idx, "WaitRegist, client Idx: %d  111", client.Idx)
	key := fmt.Sprintf("WaitRegist_%d", client.Idx)
	clientValidTimerMap[key] = clientValidTimer.NewTimer(key, int64((NetConf.WAIT_REGIST_TIME)*time.Second), func() {
		if _, ok := clientValidTimerMap[key]; ok {
			Logger.Info(LogConf.NetCoreClient, client.Idx, "WaitRegist TimeOut, client Idx: %d", client.Idx)
			client.Stop()
		}
	}, false)
	Logger.Info(LogConf.NetCoreClient, client.Idx, "WaitRegist, client Idx: %d  222", client.Idx)
}
开发者ID:ccppluagopy,项目名称:Zebra,代码行数:11,代码来源:Client.go

示例11: ServeHTTP

func (handler *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
	var task *models.Task

	err := json.NewDecoder(request.Body).Decode(&task)
	if err != nil {
		logger.Error("handler.malformed-payload", map[string]interface{}{
			"error": err.Error(),
		})

		writer.WriteHeader(http.StatusBadRequest)

		return
	}

	sleepForARandomInterval("handler.hesitate", 0, 100, map[string]interface{}{
		"task": task.Guid,
	})

	ok := handler.reserveMemory(task.MemoryMB)
	if !ok {
		logger.Info("handler.full", map[string]interface{}{
			"task": task.Guid,
		})

		writer.WriteHeader(http.StatusServiceUnavailable)

		return
	}

	logger.Info("claiming.runonce", map[string]interface{}{
		"task": task.Guid,
	})

	err = handler.bbs.ClaimTask(task, executorID)
	if err != nil {
		handler.releaseMemory(task.MemoryMB)

		logger.Info("handler.claim-failed", map[string]interface{}{
			"task":  task.Guid,
			"error": err.Error(),
		})

		writer.WriteHeader(http.StatusConflict)

		return
	}

	go handler.runTask(task)

	writer.WriteHeader(http.StatusCreated)
}
开发者ID:vito,项目名称:fake-diego-release,代码行数:51,代码来源:handler.go

示例12: handleClientRoomChat

func handleClientRoomChat(client *NetCore.Client, msg *NetCore.NetMsg) bool {
	if room, ok := idRoomMap[client.Id]; ok {
		msg.Cmd = MsgConf.ClientRoomChatBroad
		for id, v := range room.Guests {
			v.SendMsg(msg)
			Logger.Info(LogConf.WorkerClientJob, client.Idx, "handleClientRoomChat send to client: %d", id)
		}
		return true
	}

	Logger.Info(LogConf.WorkerClientJob, client.Idx, "handleClientRoomChat err: not in room id: %d", client.Id)

	return true
}
开发者ID:cokeboL,项目名称:ZIM,代码行数:14,代码来源:Room.go

示例13: process_in_moved_to

func (avl *av_list) process_in_moved_to(file string) error {
	var (
		f_a, f_v   string
		outf       string
		channel_id string
	)

	// check the file name is like ./1.1111111.1111111.a.mp4
	splitedfile := strings.Split(file, ".")
	if len(splitedfile) == 5 {
		channel_id = splitedfile[0]
	} else {
		logger.Warn("file %s is error", file)
	}

	if f, ok := (*avl)[channel_id]; ok {
		delete(*avl, channel_id)

		if string(splitedfile[3]) == "a" {
			f_a = file
			f_v = f
			outf = strings.Join(strings.Split(f, ".")[0:3], ".") + ".mp4"
		} else if string(splitedfile[3]) == "v" {
			f_v = file
			f_a = f
			outf = strings.Join(strings.Split(f, ".")[0:3], ".") + ".mp4"
		}
		logger.Info("f_v: " + f_v + ", f_a: " + f_a + ", outf: " + outf)

		time.Sleep(time.Duration(time.Second * 5))
		// merge video and audio
		cmd := exec.Command("ffmpeg", "-y", "-i", f_v, "-i", f_a, "-codec", "copy", outf)
		//cmd := exec.Command("ffmpeg", " -y -i ", f_v, "-i ", f_a, " -codec copy ", outf, " >/dev/null 2>&1 ")
		logger.Info("cmd's args is: ", cmd.Args)
		err := cmd.Run()
		if err != nil {
			logger.Fatal("ffmpeg merge video error:", err)
		} else {
			cmd = exec.Command("rm", "-f", f_v, " ", f_a)
			err = cmd.Run()
			if err != nil {
				logger.Warn("rm files error: %s", err)
			}
		}
	} else {
		(*avl)[channel_id] = file
	}
	return nil
}
开发者ID:szqh97,项目名称:test,代码行数:49,代码来源:video_merge.go

示例14: main

func main() {
	flag.Parse()

	v := appVersion()
	if version {
		fmt.Println(v)
		os.Exit(0)
	}
	logger.Info("main", v)

	cfg, err := loadConfig()
	if err != nil {
		logger.Error("main", "The configuration could not be loaded", "error", err, "path", conf)
		os.Exit(1)
	}

	// Start service
	q := qubot.Init(cfg)
	q.Handle(handlers.PingHandler, handlers.TauntHandler)
	err = q.Start()
	if err != nil {
		logger.Error("main", "Qubot could not be started", "error", err)
		q.Close()
		os.Exit(1)
	}

	// More advanced management on signals here: https://goo.gl/fuylKX
	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan,
		syscall.SIGINT, // aka os.Interrupt
		syscall.SIGTERM,
		syscall.SIGUSR1)

SELECT:
	select {
	case sig := <-sigChan:
		switch sig {
		case syscall.SIGINT, syscall.SIGTERM:
			q.Close()
		case syscall.SIGUSR1:
			q.Report()
			goto SELECT
		}
	case <-q.Done():
		logger.Info("main", "Qubot stopped")
	}

	logger.Info("main", "¡Adiós!")
}
开发者ID:sevein,项目名称:qubot,代码行数:49,代码来源:main.go

示例15: handleStaging

func handleStaging(bbs bbs.StagerBBS, natsClient yagnats.NATSClient) {
	var task uint64

	natsClient.SubscribeWithQueue("stage", "stager", func(msg *yagnats.Message) {
		var message stagingMessage

		err := json.Unmarshal(msg.Payload, &message)
		if err != nil {
			logger.Fatal("staging-request.invalid", map[string]interface{}{
				"error":   err.Error(),
				"payload": string(msg.Payload),
			})
			return
		}

		for i := 0; i < message.Count; i++ {
			guid := atomic.AddUint64(&task, 1)

			task := &models.Task{
				Guid:     fmt.Sprintf("task-%d", guid),
				MemoryMB: message.MemoryMB,

				ReplyTo: msg.ReplyTo,
			}

			logger.Info("staging-request.desire", map[string]interface{}{
				"task": task,
			})

			go bbs.DesireTask(task)
		}
	})
}
开发者ID:vito,项目名称:fake-diego-release,代码行数:33,代码来源:main.go


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