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


Golang log.Info函数代码示例

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


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

示例1: GC

// periodically scan chunks and close any that have not received data in a while
// TODO instrument occurences and duration of GC
func (ms *AggMetrics) GC() {
	ticker := time.Tick(time.Duration(*gcInterval) * time.Second)
	for now := range ticker {
		log.Info("checking for stale chunks that need persisting.")
		now := uint32(now.Unix())
		chunkMinTs := now - (now % ms.chunkSpan) - uint32(ms.chunkMaxStale)
		metricMinTs := now - (now % ms.chunkSpan) - uint32(ms.metricMaxStale)

		// as this is the only goroutine that can delete from ms.Metrics
		// we only need to lock long enough to get the list of actives metrics.
		// it doesnt matter if new metrics are added while we iterate this list.
		ms.RLock()
		keys := make([]string, 0, len(ms.Metrics))
		for k := range ms.Metrics {
			keys = append(keys, k)
		}
		ms.RUnlock()
		for _, key := range keys {
			ms.RLock()
			a := ms.Metrics[key]
			ms.RUnlock()
			if stale := a.GC(chunkMinTs, metricMinTs); stale {
				log.Info("metric %s is stale. Purging data from memory.", key)
				delete(ms.Metrics, key)
			}
		}

	}
}
开发者ID:aglagla,项目名称:raintank-metric,代码行数:31,代码来源:aggmetrics.go

示例2: InitApiPluginRoutes

func InitApiPluginRoutes(r *macaron.Macaron) {
	for _, plugin := range plugins.ApiPlugins {
		log.Info("Plugin: Adding proxy routes for api plugin")
		for _, route := range plugin.Routes {
			url := util.JoinUrlFragments("/api/plugin-proxy/", route.Path)
			handlers := make([]macaron.Handler, 0)
			if route.ReqSignedIn {
				handlers = append(handlers, middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true}))
			}
			if route.ReqGrafanaAdmin {
				handlers = append(handlers, middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true}))
			}
			if route.ReqSignedIn && route.ReqRole != "" {
				if route.ReqRole == m.ROLE_ADMIN {
					handlers = append(handlers, middleware.RoleAuth(m.ROLE_ADMIN))
				} else if route.ReqRole == m.ROLE_EDITOR {
					handlers = append(handlers, middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN))
				}
			}
			handlers = append(handlers, ApiPlugin(route.Url))
			r.Route(url, route.Method, handlers...)
			log.Info("Plugin: Adding route %s", url)
		}
	}
}
开发者ID:sumpan,项目名称:grafana,代码行数:25,代码来源:api_plugin.go

示例3: upgrade

func upgrade() {
	UpgradeFileName := getUpgradeFileName()
	VersionFileName := getVersionFileName()
	UpgradeMarkerFileName := getUpgradeMarkerFileName()

	if setting.PathExists(UpgradeFileName) {
		if loadUpgradeFile(UpgradeFileName) {
			if !setting.PathExists(VersionFileName) {
				netCrunchSettings, err := readNetCrunchServerSettings()
				if err == nil {
					if updateNetCrunchDatasources(netCrunchSettings) &&
						writeVersionFile(VersionFileName) && removeFile(UpgradeFileName) {
						log.Info("NetCrunch: Upgrade")

						if setting.PathExists(UpgradeMarkerFileName) {
							SetInitializationSuccess()
							removeFile(UpgradeMarkerFileName)
						}
					} else {
						log.Info("NetCrunch: Upgrade error")
					}
				} else {
					log.Info("NetCrunch: Upgrade error")
				}
			}
		} else {
			log.Info("NetCrunch: Upgrade error")
		}
	}
}
开发者ID:adremsoft,项目名称:NetCrunch-grafana,代码行数:30,代码来源:netcrunch.go

示例4: exec

func (mg *Migrator) exec(m Migration) error {
	if mg.LogLevel <= log.INFO {
		log.Info("Migrator: exec migration id: %v", m.Id())
	}

	err := mg.inTransaction(func(sess *xorm.Session) error {

		condition := m.GetCondition()
		if condition != nil {
			sql, args := condition.Sql(mg.dialect)
			results, err := sess.Query(sql, args...)
			if err != nil || len(results) == 0 {
				log.Info("Migrator: skipping migration id: %v, condition not fulfilled", m.Id())
				return sess.Rollback()
			}
		}

		_, err := sess.Exec(m.Sql(mg.dialect))
		if err != nil {
			log.Error(3, "Migrator: exec FAILED migration id: %v, err: %v", m.Id(), err)
			return err
		}
		return nil
	})

	if err != nil {
		return err
	}

	return nil
}
开发者ID:mbrukman,项目名称:grafana,代码行数:31,代码来源:migrator.go

示例5: run

func (h *hub) run() {
	for {
		select {
		case c := <-h.register:
			h.connections[c] = true
			log.Info("Live: New connection (Total count: %v)", len(h.connections))

		case c := <-h.unregister:
			if _, ok := h.connections[c]; ok {
				log.Info("Live: Closing Connection (Total count: %v)", len(h.connections))
				delete(h.connections, c)
				close(c.send)
			}
		// hand stream subscriptions
		case sub := <-h.subChannel:
			log.Info("Live: Subscribing to: %v, remove: %v", sub.name, sub.remove)
			subscribers, exists := h.streams[sub.name]

			// handle unsubscribe
			if exists && sub.remove {
				delete(subscribers, sub.conn)
				continue
			}

			if !exists {
				subscribers = make(map[*connection]bool)
				h.streams[sub.name] = subscribers
			}
			subscribers[sub.conn] = true

			// handle stream messages
		case message := <-h.streamChannel:
			subscribers, exists := h.streams[message.Stream]
			if !exists || len(subscribers) == 0 {
				log.Info("Live: Message to stream without subscribers: %v", message.Stream)
				continue
			}

			messageBytes, _ := simplejson.NewFromAny(message).Encode()
			for sub := range subscribers {
				// check if channel is open
				if _, ok := h.connections[sub]; !ok {
					delete(subscribers, sub)
					continue
				}

				select {
				case sub.send <- messageBytes:
				default:
					close(sub.send)
					delete(h.connections, sub)
					delete(subscribers, sub)
				}
			}
		}
	}
}
开发者ID:Xetius,项目名称:grafana,代码行数:57,代码来源:hub.go

示例6: initRuntime

func initRuntime() {
	setting.NewConfigContext(&setting.CommandLineArgs{
		Config:   *configFile,
		HomePath: *homePath,
		Args:     flag.Args(),
	})

	log.Info("Starting Grafana")
	log.Info("Version: %v, Commit: %v, Build date: %v", setting.BuildVersion, setting.BuildCommit, time.Unix(setting.BuildStamp, 0))
	setting.LogConfigurationInfo()

	sqlstore.NewEngine()
	sqlstore.EnsureAdminUser()
}
开发者ID:reduxdj,项目名称:grafana,代码行数:14,代码来源:main.go

示例7: Save

func (c *CollectorContext) Save() error {
	cmd := &m.AddCollectorSessionCommand{
		CollectorId: c.Collector.Id,
		SocketId:    c.Socket.Id(),
		OrgId:       c.OrgId,
		InstanceId:  instanceId,
	}
	if err := bus.Dispatch(cmd); err != nil {
		log.Info("could not write collector_sesison to DB.", err)
		return err
	}
	log.Info("collector_session %s for collector_id: %d saved to DB.", cmd.SocketId, cmd.CollectorId)
	return nil
}
开发者ID:reduxdj,项目名称:grafana,代码行数:14,代码来源:socketio.go

示例8: NewAggMetrics

func NewAggMetrics(chunkSpan, numChunks, chunkMaxStale, metricMaxStale uint32, aggSettings []aggSetting) *AggMetrics {
	ms := AggMetrics{
		Metrics:        make(map[string]*AggMetric),
		chunkSpan:      chunkSpan,
		numChunks:      numChunks,
		aggSettings:    aggSettings,
		chunkMaxStale:  chunkMaxStale,
		metricMaxStale: metricMaxStale,
	}
	// open data file
	dataFile, err := os.Open(*dumpFile)

	if err == nil {
		log.Info("loading aggMetrics from file " + *dumpFile)
		dataDecoder := gob.NewDecoder(dataFile)
		err = dataDecoder.Decode(&ms)
		if err != nil {
			log.Error(3, "failed to load aggMetrics from file. %s", err)
		}
		dataFile.Close()
		log.Info("aggMetrics loaded from file.")
		if ms.numChunks != numChunks {
			if ms.numChunks > numChunks {
				log.Fatal(3, "numChunks can not be decreased.")
			}
			log.Info("numChunks has changed. Updating memory structures.")
			sem := make(chan bool, *concurrency)
			for _, m := range ms.Metrics {
				sem <- true
				go func() {
					m.GrowNumChunks(numChunks)
					<-sem
				}()
			}
			for i := 0; i < cap(sem); i++ {
				sem <- true
			}

			ms.numChunks = numChunks
			log.Info("memory structures updated.")
		}
	} else {
		log.Info("starting with fresh aggmetrics.")
	}

	go ms.stats()
	go ms.GC()
	return &ms
}
开发者ID:aglagla,项目名称:raintank-metric,代码行数:49,代码来源:aggmetrics.go

示例9: exec

func (mg *Migrator) exec(m Migration) error {
	log.Info("Executing migration", "id", m.Id())

	err := mg.inTransaction(func(sess *xorm.Session) error {

		condition := m.GetCondition()
		if condition != nil {
			sql, args := condition.Sql(mg.dialect)
			results, err := sess.Query(sql, args...)
			if err != nil || len(results) == 0 {
				mg.Logger.Info("Skipping migration condition not fulfilled", "id", m.Id())
				return sess.Rollback()
			}
		}

		_, err := sess.Exec(m.Sql(mg.dialect))
		if err != nil {
			mg.Logger.Error("Executing migration failed", "id", m.Id(), "error", err)
			return err
		}
		return nil
	})

	if err != nil {
		return err
	}

	return nil
}
开发者ID:linkslice,项目名称:grafana,代码行数:29,代码来源:migrator.go

示例10: OnDisconnection

func (c *CollectorContext) OnDisconnection() {
	log.Info(fmt.Sprintf("%s disconnected", c.Collector.Name))
	if err := c.Remove(); err != nil {
		log.Error(4, fmt.Sprintf("Failed to remove collectorSession. %s", c.Collector.Name), err)
	}
	contextCache.Remove(c.SocketId)
}
开发者ID:reduxdj,项目名称:grafana,代码行数:7,代码来源:socketio.go

示例11: loadLdapConfig

func loadLdapConfig() {
	if !setting.LdapEnabled {
		return
	}

	log.Info("Login: Ldap enabled, reading config file: %s", setting.LdapConfigFile)

	_, err := toml.DecodeFile(setting.LdapConfigFile, &ldapCfg)
	if err != nil {
		log.Fatal(3, "Failed to load ldap config file: %s", err)
	}

	if len(ldapCfg.Servers) == 0 {
		log.Fatal(3, "ldap enabled but no ldap servers defined in config file: %s", setting.LdapConfigFile)
	}

	// set default org id
	for _, server := range ldapCfg.Servers {
		assertNotEmptyCfg(server.SearchFilter, "search_filter")
		assertNotEmptyCfg(server.SearchBaseDNs, "search_base_dns")

		for _, groupMap := range server.LdapGroups {
			if groupMap.OrgId == 0 {
				groupMap.OrgId = 1
			}
		}
	}
}
开发者ID:VoiSmart,项目名称:grafana,代码行数:28,代码来源:settings.go

示例12: registerPlugin

func (pb *PluginBase) registerPlugin(pluginDir string) error {
	if _, exists := Plugins[pb.Id]; exists {
		return errors.New("Plugin with same id already exists")
	}

	if !strings.HasPrefix(pluginDir, setting.StaticRootPath) {
		log.Info("Plugins: Registering plugin %v", pb.Name)
	}

	if len(pb.Dependencies.Plugins) == 0 {
		pb.Dependencies.Plugins = []PluginDependencyItem{}
	}

	if pb.Dependencies.GrafanaVersion == "" {
		pb.Dependencies.GrafanaVersion = "*"
	}

	for _, include := range pb.Includes {
		if include.Role == "" {
			include.Role = m.RoleType(m.ROLE_VIEWER)
		}
	}

	pb.PluginDir = pluginDir
	Plugins[pb.Id] = pb
	return nil
}
开发者ID:VoiSmart,项目名称:grafana,代码行数:27,代码来源:models.go

示例13: Logger

// Logger returns a middleware handler that logs the request as it goes in and the response as it goes out.
func Logger() macaron.Handler {
	return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
		start := time.Now()

		rw := res.(macaron.ResponseWriter)
		c.Next()

		content := fmt.Sprintf("Completed %s %v %s in %v", req.URL.Path, rw.Status(), http.StatusText(rw.Status()), time.Since(start))
		if !isWindows {
			switch rw.Status() {
			case 200:
				content = fmt.Sprintf("\033[1;32m%s\033[0m", content)
				return
			case 304:
				//content = fmt.Sprintf("\033[1;33m%s\033[0m", content)
				return
			case 404:
				content = fmt.Sprintf("\033[1;31m%s\033[0m", content)
			case 500:
				content = fmt.Sprintf("\033[1;36m%s\033[0m", content)
			}
		}
		log.Info(content)
	}
}
开发者ID:chengweiv5,项目名称:grafana,代码行数:26,代码来源:logger.go

示例14: newMacaron

func newMacaron() *macaron.Macaron {
	macaron.Env = setting.Env
	m := macaron.New()

	m.Use(middleware.Logger())
	m.Use(macaron.Recovery())

	if setting.EnableGzip {
		m.Use(middleware.Gziper())
	}

	for _, route := range plugins.StaticRoutes {
		pluginRoute := path.Join("/public/plugins/", route.PluginId)
		log.Info("Plugins: Adding route %s -> %s", pluginRoute, route.Directory)
		mapStatic(m, route.Directory, "", pluginRoute)
	}

	mapStatic(m, setting.StaticRootPath, "", "public")
	mapStatic(m, setting.StaticRootPath, "robots.txt", "robots.txt")

	m.Use(macaron.Renderer(macaron.RenderOptions{
		Directory:  path.Join(setting.StaticRootPath, "views"),
		IndentJSON: macaron.Env != macaron.PROD,
		Delims:     macaron.Delims{Left: "[[", Right: "]]"},
	}))

	if setting.EnforceDomain {
		m.Use(middleware.ValidateHostHeader(setting.Domain))
	}

	m.Use(middleware.GetContextHandler())
	m.Use(middleware.Sessioner(&setting.SessionOptions))

	return m
}
开发者ID:volter,项目名称:grafana,代码行数:35,代码来源:web.go

示例15: Publish

func Publish(event *schema.ProbeEvent) error {
	if !enabled {
		return nil
	}
	version := uint8(msgFormatJson)

	buf := new(bytes.Buffer)
	err := binary.Write(buf, binary.LittleEndian, version)
	if err != nil {
		log.Fatal(0, "binary.Write failed: %s", err.Error())
	}
	id := time.Now().UnixNano()
	binary.Write(buf, binary.BigEndian, id)
	if err != nil {
		log.Fatal(0, "binary.Write failed: %s", err.Error())
	}
	msg, err := json.Marshal(event)
	if err != nil {
		return fmt.Errorf("Failed to marshal event payload: %s", err)
	}
	_, err = buf.Write(msg)
	if err != nil {
		log.Fatal(0, "buf.Write failed: %s", err.Error())
	}
	collectorEventPublisherMsgs.Inc(1)
	err = globalProducer.Publish(topic, buf.Bytes())
	if err != nil {
		panic(fmt.Errorf("can't publish to nsqd: %s", err))
	}
	log.Info("event published to NSQ %d", id)

	//globalProducer.Stop()
	return nil
}
开发者ID:0x20h,项目名称:grafana,代码行数:34,代码来源:collectoreventpublisher.go


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