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


Golang log.Debug函数代码示例

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


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

示例1: 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

示例2: HttpGet

func (self *EndpointBundle) HttpGet(huddle *core.Huddle) ([]*model.Instance, error) {
	tenant := self.Parent.Parent.Tenant
	bundleType := self.BundleType

	instances, err := huddle.ListInstances(tenant, bundleType)
	if err != nil {
		return nil, err
	}
	if instances == nil {
		return nil, nil
	}

	models := []*model.Instance{}
	for _, instance := range instances {
		model, err := instance.GetState()
		if err != nil {
			return nil, err
		}

		if model == nil {
			log.Debug("Ignoring concurrently deleted (?) instance: %v", instance)
			continue
		}

		models = append(models, model)
	}

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

示例3: GetSystemBundle

func (self *BundleStore) GetSystemBundle(key string) (*Bundle, error) {
	log.Debug("Getting system bundle %v", key)

	template, err := self.GetBundleTemplate(key)
	if err != nil {
		return nil, err
	}
	if template == nil {
		return nil, nil
	}

	context := &TemplateContext{}

	config, err := template.executeTemplate(context)
	if err != nil {
		return nil, err
	}

	bundle, err := parseBundle(config)
	if err != nil {
		return nil, err
	}

	//	bundle, err := getOnly(bundles)
	//	if err != nil {
	//		return nil, err
	//	}

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

示例4: waitReady

func waitReady(instance *core.Instance, timeout int) (bool, error) {
	ready := false
	for i := 0; i < timeout; i++ {
		state, err := instance.GetState()
		if err != nil {
			log.Warn("Error while waiting for instance to become ready", err)
			return false, err
		}

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

		if status == "started" {
			ready = true
			break
		}

		time.Sleep(time.Second)
		if status == "pending" {
			log.Debug("Instance not ready; waiting", err)
		} else {
			log.Warn("Unknown instance status: %v", status)
		}
	}

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

示例5: parseReturn

func parseReturn(out []reflect.Value) (reflect.Value, error) {
	var value reflect.Value
	var err error

	if len(out) >= 2 {
		// TODO: Don't assume position 1?
		errValue := out[1]
		if !errValue.IsNil() {
			var ok bool
			log.Debug("Got error value from rs method: %v", errValue)
			err, ok = errValue.Interface().(error)
			if !ok {
				err = fmt.Errorf("Unable to cast value to error")
			}
		}
	}

	if err == nil && len(out) > 0 {
		// TODO: Don't assume position 0
		value = out[0]

		if !value.IsValid() {
			value = reflect.ValueOf(nil)
		}
	}

	return value, err
}
开发者ID:justinsb,项目名称:gova,代码行数:28,代码来源:rs.go

示例6: Deploy

func (self *Bundle) Deploy(jujuPrefix string, apiclient *juju.Client) (*DeployInfo, error) {
	log.Debug("Deploying bundle: %v", self)

	info := &DeployInfo{}
	info.Services = map[string]*DeployServiceInfo{}

	for key, service := range self.Services {
		serviceInfo, err := service.deploy(jujuPrefix+key, apiclient)
		if err != nil {
			return nil, err
		}
		info.Services[key] = serviceInfo
	}

	for _, relation := range self.Relations {
		prefixed := &RelationConfig{}
		prefixed.From = jujuPrefix + relation.From
		prefixed.To = jujuPrefix + relation.To

		err := prefixed.deploy(apiclient)
		if err != nil {
			return nil, err
		}
	}

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

示例7: 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

示例8: ListInstances

func (self *Huddle) ListInstances(tenant string, bundleType bundletype.BundleType) ([]*Instance, error) {
	prefix := self.jujuPrefix(tenant, bundleType)

	statuses, err := self.JujuClient.GetServiceStatusList(prefix)
	if err != nil {
		return nil, err
	}
	if statuses == nil {
		return nil, rs.HttpError(http.StatusNotFound)
	}

	instances := []*Instance{}
	for key, state := range statuses {
		_, bundleTypeId, instanceId, module, _, err := ParseUnit(key)
		if err != nil {
			log.Debug("Ignoring unparseable service: %v", key)
			continue
		}

		assert.That(bundleTypeId == bundleType.Key())

		if module != bundleType.PrimaryJujuService() {
			continue
		}

		i := self.NewInstance(tenant, bundleType, instanceId)
		i.cacheState(&state)

		instances = append(instances, i)
	}

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

示例9: buildArg

func (self *RestEndpointHandler) buildArg(req *http.Request, t reflect.Type) (interface{}, error) {
	v, err := self.server.injector.Get(t)
	if err == nil && v != nil {
		return v, nil
	}

	// TODO: Fail if two args...

	// TODO: Only if has content?
	mediaType, err := getMediaType(req)
	if err != nil {
		return nil, err
	}

	if mediaType == nil {
		// Go does have a function to guess the media type, but that seems risky
		// Instead, use a fixed default
		mediaType = self.server.defaultMediaType
	}

	v, err = self.server.readMessageBody(t, req, mediaType)
	if err != nil {
		if err == io.EOF {
			log.Debug("Error reading message body (EOF)")
		} else {
			log.Debug("Error reading message body", err)
		}
		err = HttpError(http.StatusBadRequest)
		return nil, err
	}

	if v == nil && err == nil {
		err = HttpError(http.StatusUnsupportedMediaType)
		return nil, err
	}

	if v != nil {
		assert.Equal(reflect.TypeOf(v), t)
		return v, nil
	}

	log.Warn("Unable to bind parameter: %v", t)
	return nil, fmt.Errorf("Unable to bind parameter: %v", t)
}
开发者ID:justinsb,项目名称:gova,代码行数:44,代码来源:rs.go

示例10: AddTask

func (self *Scheduler) AddTask(task Runnable, interval time.Duration) *ScheduledTask {
	scheduledTask := &ScheduledTask{}
	scheduledTask.task = task
	scheduledTask.scheduler = self
	scheduledTask.interval = interval

	go scheduledTask.run()

	log.Debug("Scheduled task: %v for interval %v", task, interval)

	return scheduledTask
}
开发者ID:jxaas,项目名称:jxaas,代码行数:12,代码来源:scheduler.go

示例11: ListAllInstances

func (self *Huddle) ListAllInstances() ([]*Instance, error) {
	prefix := "u"

	statuses, err := self.JujuClient.GetServiceStatusList(prefix)
	if err != nil {
		return nil, err
	}
	if statuses == nil {
		return nil, rs.HttpError(http.StatusNotFound)
	}

	instances := []*Instance{}
	for key, state := range statuses {
		tenant, bundleTypeId, instanceId, module, _, err := ParseUnit(key)
		if err != nil {
			log.Debug("Ignoring unparseable service: %v", key)
			continue
		}

		bundleType := self.System.GetBundleType(bundleTypeId)
		if bundleType == nil {
			log.Debug("Ignoring unknown bundle type: %v", bundleTypeId)
			continue
		}

		if module != bundleType.PrimaryJujuService() {
			continue
		}

		i := self.NewInstance(tenant, bundleType, instanceId)
		i.cacheState(&state)

		instances = append(instances, i)
	}

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

示例12: ReadLog

func (self *JujuLogStore) ReadLog(service string, unitId int) (*JujuLog, error) {
	// TODO: Block path traversal
	filename := "unit-" + service + "-" + strconv.Itoa(unitId) + ".log"
	path := path.Join(self.BaseDir, filename)
	ok, err := files.Exists(path)
	if err != nil {
		return nil, err
	}
	if !ok {
		log.Debug("Log file not found: %v", path)
		return nil, nil
	}
	log := &JujuLog{}
	log.path = path
	return log, nil
}
开发者ID:jxaas,项目名称:jxaas,代码行数:16,代码来源:logs.go

示例13: BuildRelationInfo

func (self *baseBundleType) BuildRelationInfo(templateContext *bundle.TemplateContext, bundle *bundle.Bundle, relationKey string) (*model.RelationInfo, error) {
	log.Info("BuildRelationInfo with %v", templateContext)

	// Find the properties the juju charm is exposing
	relationProperties := templateContext.Relations[relationKey]

	// Map those properties using the definition
	provideProperties := map[string]string{}

	if len(bundle.Provides) == 0 {
		// No explicit provides => derive automatically
		for k, v := range relationProperties {
			v = templateContext.GetSpecialProperty(relationKey, k, v)
			provideProperties[k] = v
		}

		// Auto-populate required properties that we generate
		required := []string{"protocol", "port"}
		for _, k := range required {
			v, found := relationProperties[k]
			if !found {
				v = templateContext.GetSpecialProperty(relationKey, k, v)
			}
			provideProperties[k] = v
		}

	} else {
		definition, found := bundle.Provides[relationKey]
		if !found {
			// Explicit provides, but no definition => no relation
			log.Debug("Request for relation, but no definition found: %v", relationKey)
			return nil, nil
		}

		for k, v := range definition.Properties {
			provideProperties[k] = v
		}
	}

	relationInfo := &model.RelationInfo{}
	if templateContext.Proxy != nil {
		relationInfo.PublicAddresses = []string{templateContext.Proxy.Host}
	}
	relationInfo.Properties = provideProperties

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

示例14: HttpGet

func (self *EndpointInstanceHealth) HttpGet() (*model.Health, error) {
	instance := self.Parent.getInstance()
	repair := false

	// TODO: Use state stored by scheduled health check, rather than running directly?
	health, err := instance.RunHealthCheck(repair)
	if err != nil {
		return nil, err
	}
	if health == nil {
		return nil, rs.ErrNotFound()
	}

	log.Debug("Health of %v: %v", instance, health)

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

示例15: executeTemplate

func (self *BundleTemplate) executeTemplate(context *TemplateContext) (map[string]interface{}, error) {
	//	t, err := template.New("bundle").Parse(templateString)
	//	if err != nil {
	//		return nil, err
	//	}

	//	log.Debug("Executing bundle template: %v", serviceType)

	var err error

	result, err := self.template.Render(context)

	if err != nil {
		log.Warn("Error applying template", err)
		return nil, err
	}

	log.Debug("Applied template: %v", result)

	resultMap, ok := result.(map[string]interface{})
	if !ok {
		log.Warn("Template did not produce map type: %T", result)
		return nil, fmt.Errorf("Unexpected result from template")
	}

	//	config := map[string]interface{}{}
	//	err := goyaml.Unmarshal([]byte(yaml), &config)
	//	if err != nil {
	//		return nil, err
	//	}

	//	var buffer bytes.Buffer
	//	err := self.template.Execute(&buffer, &templateContextCopy)
	//	if err != nil {
	//		return nil, err
	//	}

	//	yaml := buffer.String()
	//	log.Debug("Bundle is:\n%v", yaml)

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


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