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


Golang log.Info函数代码示例

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


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

示例1: addCharmViaAPI

// addCharmViaAPI calls the appropriate client API calls to add the
// given charm URL to state. Also displays the charm URL of the added
// charm on stdout.
func addCharmViaAPI(client *api.Client, curl *charm.URL, repo charm.Repository) (*charm.URL, error) {
	if curl.Revision < 0 {
		latest, err := charm.Latest(repo, curl)
		if err != nil {
			log.Info("Error find latest version for: %v", curl.String(), err)
			return nil, err
		}
		curl = curl.WithRevision(latest)
	}
	switch curl.Schema {
	case "local":
		ch, err := repo.Get(curl)
		if err != nil {
			return nil, err
		}
		stateCurl, err := client.AddLocalCharm(curl, ch)
		if err != nil {
			return nil, err
		}
		curl = stateCurl
	case "cs":
		err := client.AddCharm(curl)
		if err != nil {
			return nil, err
		}
	default:
		return nil, fmt.Errorf("unsupported charm URL schema: %q", curl.Schema)
	}
	log.Info("Added charm %q to the environment.", curl)
	return curl, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:34,代码来源:charm.go

示例2: HttpGet

func (self *EndpointServiceInstance) HttpGet() (*rs.HttpResponse, error) {
	service := self.getService()

	log.Info("CF instance GET request: %v", self.Id)

	bundleType, instance := service.getInstance(self.Id)
	if instance == nil || bundleType == nil {
		return nil, rs.ErrNotFound()
	}

	state, err := instance.GetState()
	if err != nil {
		log.Warn("Error while waiting for instance to become ready", err)
		return nil, err
	}

	ready := false
	if state == nil {
		log.Warn("Instance not yet created")
	} else {
		status := state.Status

		if status == "started" {
			ready = true
		} else if status == "pending" {
			ready = false
		} else {
			log.Warn("Unknown instance status: %v", status)
		}
	}

	response := &CfCreateInstanceResponse{}
	// TODO: We need a dashboard URL - maybe a Juju GUI?
	response.DashboardUrl = "http://localhost:8080"
	var cfState string
	if ready {
		cfState = CF_STATE_SUCCEEDED
	} else {
		cfState = CF_STATE_IN_PROGRESS
	}
	response.State = cfState
	response.LastOperation = &CfOperation{}
	response.LastOperation.State = cfState

	log.Info("Sending response to CF service get", log.AsJson(response))

	httpResponse := &rs.HttpResponse{Status: http.StatusOK}
	httpResponse.Content = response
	return httpResponse, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:50,代码来源:service_instance.go

示例3: listSubkeys

func (self *EtcdRouterRegistry) listSubkeys(key string) ([]string, error) {
	response, err := self.client.Get(key, false, false)
	if err != nil {
		etcdError, ok := err.(*etcd.EtcdError)
		if ok && etcdError.ErrorCode == etcdErrorKeyNotFound {
			log.Debug("Etcd key not found: %v", key)
			return []string{}, nil
		}

		log.Warn("Error reading key from etcd: %v", key, err)
		return nil, err
	}

	if response == nil || response.Node == nil || response.Node.Nodes == nil {
		log.Info("No children for key from etcd: %v", key)
		return []string{}, nil
	}

	names := []string{}
	for _, node := range response.Node.Nodes {
		nodeKey := node.Key
		if !strings.HasPrefix(nodeKey, key) {
			return nil, fmt.Errorf("Key without expected prefix: %v vs %v", nodeKey, key)
		}
		suffix := nodeKey[len(key):]
		names = append(names, suffix)
	}
	return names, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:29,代码来源:etcd_router_registry.go

示例4: getCharmInfo

func getCharmInfo(client *api.Client, charmName string, localRepoPath string, defaultSeries string) (*api.CharmInfo, error) {
	curl, err := resolveCharmURL(client, charmName, defaultSeries)
	if err != nil {
		return nil, err
	}

	repo, err := charm.InferRepository(curl.Reference, localRepoPath)
	if err != nil {
		return nil, err
	}

	//	repo = config.SpecializeCharmRepo(repo, defaultSeries)

	curl, err = addCharmViaAPI(client, curl, repo)
	if err != nil {
		return nil, err
	}

	charmInfo, err := client.CharmInfo(curl.String())
	if err != nil {
		log.Info("Error getting charm info for: %v", curl.String(), err)
		return nil, err
	}
	return charmInfo, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:25,代码来源:charm.go

示例5: read

func (self *EtcdRouterRegistry) read(key string) (*etcdRouterData, error) {
	response, err := self.client.Get(key, false, false)
	if err != nil {
		etcdError, ok := err.(*etcd.EtcdError)
		if ok && etcdError.ErrorCode == etcdErrorKeyNotFound {
			log.Debug("Etcd key not found: %v", key)
			return nil, nil
		}

		log.Warn("Error reading key from etcd: %v", key, err)
		return nil, err
	}

	node := response.Node
	if node == nil || node.Value == "" {
		log.Info("No contents for key from etcd: %v", key)
		return nil, nil
	}

	decoded := &etcdRouterData{}
	err = json.Unmarshal([]byte(node.Value), decoded)
	if err != nil {
		log.Warn("Error parsing value from etcd: %v", node.Value, err)
		return nil, err
	}

	return decoded, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:28,代码来源:etcd_router_registry.go

示例6: HttpDelete

func (self *EndpointServiceInstance) HttpDelete(httpRequest *http.Request) (*CfDeleteInstanceResponse, error) {
	service := self.getService()

	queryValues := httpRequest.URL.Query()
	serviceId := queryValues.Get("service_id")
	//	planId := queryValues.Get("plan_id")

	if serviceId != service.CfServiceId {
		log.Warn("Service mismatch: %v vs %v", serviceId, service.CfServiceId)
		return nil, rs.ErrNotFound()
	}

	log.Info("Deleting item %v %v", serviceId, self.Id)

	bundletype, instance := service.getInstance(self.getInstanceId())
	if instance == nil || bundletype == nil {
		return nil, rs.ErrNotFound()
	}

	err := instance.Delete()
	if err != nil {
		return nil, err
	}

	// TODO: Wait for deletion?

	response := &CfDeleteInstanceResponse{}
	return response, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:29,代码来源:service_instance.go

示例7: HttpPut

func (self *EndpointInstanceScaling) HttpPut(policyUpdate *model.ScalingPolicy) (*model.Scaling, error) {
	instance := self.Parent.getInstance()

	log.Info("Policy update: %v", policyUpdate)

	exists, err := instance.Exists()
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, rs.ErrNotFound()
	}

	if policyUpdate != nil {
		_, err := instance.UpdateScalingPolicy(policyUpdate)
		if err != nil {
			log.Warn("Error updating scaling policy", err)
			return nil, err
		}
	}

	results, err := instance.RunScaling(true)
	if err != nil {
		return nil, err
	}
	return results, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:27,代码来源:instance_scaling.go

示例8: DeleteRelationInfo

// Delete any relation properties relating to the specified unit; that unit is going away.
func (self *Instance) DeleteRelationInfo(unitId string, relationId string) error {
	jujuClient := self.GetJujuClient()

	serviceId := self.primaryServiceId

	prefix := ANNOTATION_PREFIX_RELATIONINFO + unitId + "_" + relationId + "_"

	annotations, err := jujuClient.GetServiceAnnotations(serviceId)
	if err != nil {
		log.Warn("Error getting annotations", err)
		// TODO: Mask error?
		return err
	}

	deleteKeys := []string{}

	for tagName, _ := range annotations {
		if !strings.HasPrefix(tagName, prefix) {
			continue
		}
		deleteKeys = append(deleteKeys, tagName)
	}

	if len(deleteKeys) != 0 {
		log.Info("Deleting annotations on service %v: %v", serviceId, deleteKeys)

		err = jujuClient.DeleteServiceAnnotations(serviceId, deleteKeys)
		if err != nil {
			log.Warn("Error deleting annotations", err)
			return err
		}
	}

	return nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:36,代码来源:instance.go

示例9: localIP

func localIP() (net.IP, error) {
	netInterfaces, err := net.Interfaces()
	if err != nil {
		return nil, err
	}
	for _, netInterface := range netInterfaces {
		addresses, err := netInterface.Addrs()
		if err != nil {
			return nil, err
		}
		for _, address := range addresses {
			ipnet, ok := address.(*net.IPNet)
			if !ok {
				continue
			}
			v4 := ipnet.IP.To4()
			if v4 == nil || v4[0] == 127 { // loopback address
				continue
			}
			log.Info("Chose local IP: %v", v4)
			return v4, nil
		}
	}
	return nil, errors.New("Cannot find local IP address")
}
开发者ID:jxaas,项目名称:jxaas,代码行数:25,代码来源:options.go

示例10: GetOptions

func GetOptions() *Options {
	flag.Parse()

	self := &Options{}

	self.AgentConf = *flagAgentConf
	self.ApiPasswordPath = *flagApiPasswordPath

	self.CfTenantId = *flagCfTenantId
	self.ListenAddress = *flagListenAddress

	host, port, err := net.SplitHostPort(self.ListenAddress)
	if err != nil {
		log.Warn("Cannot parse listen address: %v", self.ListenAddress)
		return nil
	}
	var portNum int
	if port == "" {
		portNum = 8080
	} else {
		portNum, err = net.LookupPort("tcp", port)
		if err != nil {
			log.Warn("Cannot resolve port: %v", port)
			return nil
		}
	}

	privateUrl := *flagPrivateUrl
	if privateUrl == "" {
		privateHost := host
		if privateHost == "" {
			ip, err := localIP()
			if err != nil {
				log.Warn("Error finding local IP", err)
				return nil
			}
			privateHost = ip.String()
		}

		privateUrl = fmt.Sprintf("http://%v:%v/xaasprivate", privateHost, portNum)
		log.Info("Chose private url: %v", privateUrl)
	}
	self.PrivateUrl = privateUrl

	authMode := *flagAuth
	authMode = strings.TrimSpace(authMode)
	authMode = strings.ToLower(authMode)
	if authMode == "openstack" {
		keystoneUrl := *flagKeystoneUrl
		self.Authenticator = auth.NewOpenstackMultiAuthenticator(keystoneUrl)
	} else if authMode == "development" {
		self.Authenticator = auth.NewDevelopmentAuthenticator()
	} else {
		log.Warn("Unknown authentication mode: %v", authMode)
		return nil
	}

	return self
}
开发者ID:jxaas,项目名称:jxaas,代码行数:59,代码来源:options.go

示例11: HttpPost

// update_relation_properties RPC handler
func (self *EndpointRpcUpdateRelationProperties) HttpPost(huddle *core.Huddle, request *RpcUpdateRelationPropertiesRequest) (*RpcUpdateRelationPropertiesResponse, error) {
	// TODO: Validate that this is coming from one of our machines?

	log.Info("Got RPC request: UpdateRelationProperties: %v", request)

	response := &RpcUpdateRelationPropertiesResponse{}

	// Sanitize
	if request.Properties == nil {
		request.Properties = make(map[string]string)
	}

	localUnit := request.ServiceName
	if localUnit == "" {
		return nil, fmt.Errorf("ServiceName is required")
	}
	tenant, bundleTypeName, instanceId, _, _, err := core.ParseUnit(localUnit)
	if err != nil {
		return nil, err
	}

	bundleType := huddle.System.GetBundleType(bundleTypeName)
	if bundleType == nil {
		return nil, fmt.Errorf("Unknown bundle type: %v", bundleTypeName)
	}

	primaryService := bundleType.PrimaryJujuService()

	//	remoteUnit := request.RemoteName
	//	if remoteUnit == "" {
	//		// We're a bit stuck here.  We do have the relationId and other info,
	//		// we just don't have the remote relation, and we're storing the attributes on the remote relation
	//		// TODO: Infer the remote relation? (-stubclient to -primary)?
	//		log.Warn("No remote unit; can't remove relations")
	//		return response, nil
	//	}
	//
	//	_, _, remoteInstanceId, _, remoteUnitId, err := core.ParseUnit(remoteUnit)
	//	if err != nil {
	//		return nil, err
	//	}

	instance := huddle.NewInstance(tenant, bundleType, instanceId)

	relationId := request.RelationId

	if request.Action == "broken" {
		err = instance.DeleteRelationInfo(primaryService, relationId)
	} else {
		err = instance.SetRelationInfo(primaryService, relationId, request.Properties)
	}

	if err != nil {
		return nil, err
	}

	return response, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:59,代码来源:rpc.go

示例12: isHuddleReady

func isHuddleReady(huddle *core.Huddle) bool {
	for key, service := range huddle.SystemServices {
		if service.PublicAddress == "" {
			log.Info("Service not ready (no public address): %v", key)
			return false
		}
	}
	return true
}
开发者ID:jxaas,项目名称:jxaas,代码行数:9,代码来源:main.go

示例13: checkService

func (self *ServiceHealthCheck) checkService(instance jxaas.Instance, serviceId string, repair bool, dest *model.Health) error {
	client := instance.GetJujuClient()

	command := "service " + self.ServiceName + " status"
	log.Info("Running command on %v: %v", serviceId, command)

	runResults, err := client.Run(serviceId, nil, command, 5*time.Second)
	if err != nil {
		return err
	}

	for _, runResult := range runResults {
		unitId := juju.ParseUnit(runResult.UnitId)

		code := runResult.Code
		stdout := string(runResult.Stdout)
		stderr := string(runResult.Stderr)

		log.Debug("Result: %v %v %v %v", runResult.UnitId, code, stdout, stderr)

		healthy := true
		if !strings.Contains(stdout, "start/running") {
			log.Info("Service %v not running on %v", serviceId, runResult.UnitId)
			healthy = false

			if repair {
				command := "service " + self.ServiceName + " start"
				log.Info("Running command on %v: %v", serviceId, command)

				_, err := client.Run(serviceId, []string{unitId}, command, 5*time.Second)
				if err != nil {
					return err
				}

			}
		}

		dest.Units[unitId] = healthy
	}

	return nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:42,代码来源:servicecheck.go

示例14: ApplyImplicits

func (self *Bundle) ApplyImplicits(templateContext *TemplateContext) {
	for _, v := range self.Services {
		v.applyImplicits(templateContext)
	}

	for _, v := range self.Relations {
		v.applyImplicits(templateContext)
	}

	for k, v := range self.Provides {
		v.applyImplicits(templateContext, k)
	}

	stub, found := self.Services["sc"]
	if found {
		self.configureStubClient(templateContext, stub)
		log.Info("Configured stubclient: %v", stub)
	} else {
		log.Info("sc (stubclient) not found")
	}
}
开发者ID:jxaas,项目名称:jxaas,代码行数:21,代码来源:implicits.go

示例15: read

func (self *CharmReader) read(name string) ([]byte, error) {
	inputStream, err := self.byteSource.Open()
	if err != nil {
		return nil, err
	}

	defer func() {
		closeable, ok := inputStream.(io.Closer)
		if ok {
			closeable.Close()
		}
	}()

	size, err := self.byteSource.Size()
	if err != nil {
		return nil, err
	}

	readerAt, ok := inputStream.(io.ReaderAt)
	if !ok {
		return nil, fmt.Errorf("Expected ReaderAt")
	}

	r, err := zip.NewReader(readerAt, size)
	if err != nil {
		return nil, err
	}

	for _, f := range r.File {
		log.Info("File: %v", f.Name)
	}

	for _, f := range r.File {
		if f.Name != name {
			continue
		}

		rc, err := f.Open()
		if err != nil {
			return nil, err
		}
		defer rc.Close()

		data, err := ioutil.ReadAll(rc)
		if err != nil {
			return nil, err
		}

		return data, nil
	}

	return nil, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:53,代码来源:charm_parser.go


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