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


Golang log.Debug函数代码示例

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


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

示例1: Write

// Write puts a value back into the manager. Example usage:
// Default Scope: Write(config.Path("currency", "option", "base"), config.Value("USD"))
// Website Scope: Write(config.Path("currency", "option", "base"), config.Value("EUR"), config.ScopeWebsite(w))
// Store   Scope: Write(config.Path("currency", "option", "base"), config.ValueReader(resp.Body), config.ScopeStore(s))
func (m *Manager) Write(o ...ArgFunc) error {
	a, err := newArg(o...)
	if err != nil {
		return log.Error("config.Manager.Write.newArg", "err", err)
	}

	if a.isBubbling() {
		if log.IsDebug() {
			log.Debug("config.Manager.Write.isBubbling", "path", a.scopePathDefault(), "bubble", a.isBubbling(), "val", a.v)
		}
		m.v.Set(a.scopePathDefault(), a.v)
		aDefault := a
		aDefault.sg = ScopeDefaultID
		aDefault.si = ScopeID(0)
		m.sendMsg(aDefault)
	}

	if log.IsDebug() {
		log.Debug("config.Manager.Write", "path", a.scopePath(), "val", a.v)
	}
	a.scopeID()
	m.v.Set(a.scopePath(), a.v)
	m.sendMsg(a)
	return nil
}
开发者ID:optimuse,项目名称:csfw,代码行数:29,代码来源:manager.go

示例2: TestNull

func TestNull(t *testing.T) {
	log.SetNull()
	log.SetLevel(-1000)
	if log.IsTrace() {
		t.Error("There should be no trace")
	}
	if log.IsDebug() {
		t.Error("There should be no debug")
	}
	if log.IsInfo() {
		t.Error("There should be no info")
	}
	if log.IsWarn() {
		t.Error("There should be no warn")
	}
	var args []interface{}
	args = append(args, "key1", 1, "key2", 3.14152)

	log.Trace("Hello World", args...)
	log.Debug("Hello World", args...)
	log.Info("Hello World", args...)
	log.Warn("Hello World", args...)
	log.Error("Hello World", args...)
	log.Log(1, "Hello World", args)
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:25,代码来源:log_test.go

示例3: Write

// Write puts a value back into the manager. Example usage:
// Default Scope: Write(config.Path("currency", "option", "base"), config.Value("USD"))
// Website Scope: Write(config.Path("currency", "option", "base"), config.Value("EUR"), config.ScopeWebsite(w))
// Store   Scope: Write(config.Path("currency", "option", "base"), config.ValueReader(resp.Body), config.ScopeStore(s))
func (m *Manager) Write(o ...ArgFunc) error {
	a := newArg(o...)
	if a.isBubbling() {
		if log.IsDebug() {
			log.Debug("Manager=Write", "path", a.scopePathDefault(), "bubble", a.isBubbling(), "val", a.v)
		}
		m.v.Set(a.scopePathDefault(), a.v)
	}

	if log.IsDebug() {
		log.Debug("Manager=Write", "path", a.scopePath(), "val", a.v)
	}
	m.v.Set(a.scopePath(), a.v)

	return nil
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:20,代码来源:manager.go

示例4: ToIntSliceE

func ToIntSliceE(i interface{}) ([]int, error) {
	if log.IsDebug() {
		log.Debug("cast=ToIntSliceE", "type", reflect.TypeOf(i), "value", i)
	}

	if i == nil {
		return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
	}

	switch v := i.(type) {
	case []int:
		return v, nil
	}

	kind := reflect.TypeOf(i).Kind()
	switch kind {
	case reflect.Slice, reflect.Array:
		s := reflect.ValueOf(i)
		a := make([]int, s.Len())
		for j := 0; j < s.Len(); j++ {
			val, err := ToIntE(s.Index(j).Interface())
			if err != nil {
				return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
			}
			a[j] = val
		}
		return a, nil
	default:
		return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
	}

	return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:33,代码来源:caste.go

示例5: ToStringMapBoolE

func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
	if log.IsDebug() {
		log.Debug("cast=ToStringMapBoolE", "type", reflect.TypeOf(i), "value", i)
	}

	var m = map[string]bool{}

	switch v := i.(type) {
	case map[interface{}]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToBool(val)
		}
		return m, nil
	case map[string]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToBool(val)
		}
		return m, nil
	case map[string]bool:
		return v, nil
	default:
		return m, fmt.Errorf("Unable to Cast %#v to map[string]bool", i)
	}
	return m, fmt.Errorf("Unable to Cast %#v to map[string]bool", i)
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:25,代码来源:caste.go

示例6: ToStringE

func ToStringE(i interface{}) (string, error) {
	i = indirectToStringerOrError(i)
	if log.IsDebug() {
		log.Debug("cast=ToStringE", "type", reflect.TypeOf(i), "value", i)
	}

	switch s := i.(type) {
	case string:
		return s, nil
	case float64:
		return strconv.FormatFloat(i.(float64), 'f', -1, 64), nil
	case int:
		return strconv.FormatInt(int64(i.(int)), 10), nil
	case []byte:
		return string(s), nil
	case template.HTML:
		return string(s), nil
	case nil:
		return "", nil
	case fmt.Stringer:
		return s.String(), nil
	case error:
		return s.Error(), nil
	default:
		return "", fmt.Errorf("Unable to Cast %#v to string", i)
	}
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:27,代码来源:caste.go

示例7: ToStringSliceE

// ToStringSliceE casts an empty interface to a []string.
func ToStringSliceE(i interface{}) ([]string, error) {
	if log.IsDebug() {
		log.Debug("cast.ToStringSliceE", "type", reflect.TypeOf(i), "value", i)
	}

	var a []string

	switch v := i.(type) {
	case []interface{}:
		for _, u := range v {
			a = append(a, ToString(u))
		}
		return a, nil
	case []string:
		return v, nil
	case string:
		return strings.Fields(v), nil
	case interface{}:
		str, err := ToStringE(v)
		if err != nil {
			return a, fmt.Errorf("Unable to Cast %#v to []string", i)
		}
		return []string{str}, nil
	default:
		return a, fmt.Errorf("Unable to Cast %#v to []string", i)
	}
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:28,代码来源:caste.go

示例8: ToFloat64E

func ToFloat64E(i interface{}) (float64, error) {
	i = indirect(i)
	if log.IsDebug() {
		log.Debug("cast=ToFloat64E", "type", reflect.TypeOf(i), "value", i)
	}

	switch s := i.(type) {
	case float64:
		return s, nil
	case float32:
		return float64(s), nil
	case int64:
		return float64(s), nil
	case int32:
		return float64(s), nil
	case int16:
		return float64(s), nil
	case int8:
		return float64(s), nil
	case int:
		return float64(s), nil
	case string:
		v, err := strconv.ParseFloat(s, 64)
		if err == nil {
			return float64(v), nil
		} else {
			return 0.0, fmt.Errorf("Unable to Cast %#v to float", i)
		}
	default:
		return 0.0, fmt.Errorf("Unable to Cast %#v to float", i)
	}
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:32,代码来源:caste.go

示例9: SetMandrill

// SetMandrill sets the Mandrill API for sending emails. This function is not
// recursive and returns nil. @todo
func SetMandrill(opts ...MandrillOptions) DaemonOption {
	return func(da *Daemon) DaemonOption {
		// this whole func is just a quick write down. no idea if it's working
		// and refactor ... 8-)
		apiKey := da.Config.GetString(config.ScopeStore(da.ScopeID), config.Path(PathSmtpMandrillAPIKey))

		if apiKey == "" {
			da.lastErrs = append(da.lastErrs, errors.New("Mandrill API Key is empty."))
			return nil
		}

		md, err := gochimp.NewMandrill(apiKey)
		if err != nil {
			da.lastErrs = append(da.lastErrs, err)
			return nil
		}
		for _, o := range opts {
			o(md)
		}

		da.sendFunc = func(from string, to []string, msg io.WriterTo) error {

			// @todo figure out if "to" contains To, CC and BCC addresses.

			addr, err := mail.ParseAddress(from)
			if err != nil {
				return log.Error("mail.daemon.Mandrill.ParseAddress", "err", err, "from", from, "to", to)
			}

			r := gochimp.Recipient{
				Name:  addr.Name,
				Email: addr.Address,
			}

			var buf bytes.Buffer
			if _, err := msg.WriteTo(&buf); err != nil {
				return log.Error("mail.daemon.Mandrill.MessageWriteTo", "err", err, "from", from, "to", to, "msg", buf.String())
			}

			resp, err := md.MessageSendRaw(buf.String(), to, r, false)
			if err != nil {
				return log.Error("mail.daemon.Mandrill.MessageSendRaw", "err", err, "from", from, "to", to, "msg", buf.String())
			}
			if log.IsDebug() {
				log.Debug("mail.daemon.Mandrill.MessageSendRaw", "resp", resp, "from", from, "to", to, "msg", buf.String())
			}
			// The last arg in MessageSendRaw means async in the Mandrill API:
			// Async: enable a background sending mode that is optimized for bulk sending.
			// In async mode, messages/send will immediately return a status of "queued"
			// for every recipient. To handle rejections when sending in async mode, set
			// up a webhook for the 'reject' event. Defaults to false for messages with
			// no more than 10 recipients; messages with more than 10 recipients are
			// always sent asynchronously, regardless of the value of async.
			return nil
		}
		da.dialer = nil

		return nil
	}
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:62,代码来源:daemon_mandrill.go

示例10: ApplyDefaults

// ApplyDefaults reads the map and applies the keys and values to the default configuration
func (m *Manager) ApplyDefaults(ss Sectioner) *Manager {
	for k, v := range ss.Defaults() {
		if log.IsDebug() {
			log.Debug("config.Manager.ApplyDefaults", k, v)
		}
		m.v.Set(k, v)
	}
	return m
}
开发者ID:optimuse,项目名称:csfw,代码行数:10,代码来源:manager.go

示例11: ToStringMapStringSliceE

// ToStringMapStringSliceE casts an empty interface to a map[string][]string.
func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
	if log.IsDebug() {
		log.Debug("cast.ToStringMapStringSliceE", "type", reflect.TypeOf(i), "value", i)
	}

	var m = map[string][]string{}

	switch v := i.(type) {
	case map[string][]string:
		return v, nil
	case map[string][]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[string]string:
		for k, val := range v {
			m[ToString(k)] = []string{val}
		}
	case map[string]interface{}:
		for k, val := range v {
			m[ToString(k)] = []string{ToString(val)}
		}
		return m, nil
	case map[interface{}][]string:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[interface{}]string:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[interface{}][]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[interface{}]interface{}:
		for k, val := range v {
			key, err := ToStringE(k)
			if err != nil {
				return m, fmt.Errorf("Unable to Cast %#v to map[string][]string", i)
			}
			value, err := ToStringSliceE(val)
			if err != nil {
				return m, fmt.Errorf("Unable to Cast %#v to map[string][]string", i)
			}
			m[key] = value
		}
	default:
		return m, fmt.Errorf("Unable to Cast %#v to map[string][]string", i)
	}
	return m, nil
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:57,代码来源:caste.go

示例12: TestNull

func TestNull(t *testing.T) {
	log.SetLevel(-1000)
	if !log.IsDebug() {
		t.Error("There should be debug logging")
	}
	if !log.IsInfo() {
		t.Error("There should be info logging")
	}
	var args []interface{}
	args = append(args, "key1", 1, "key2", 3.14152)

	log.Debug("Hello World", args...)
	log.Info("Hello World", args...)
}
开发者ID:levcom,项目名称:csfw,代码行数:14,代码来源:log_test.go

示例13: ToDurationE

func ToDurationE(i interface{}) (d time.Duration, err error) {
	i = indirect(i)
	if log.IsDebug() {
		log.Debug("cast=ToDurationE", "type", reflect.TypeOf(i), "value", i)
	}
	switch s := i.(type) {
	case time.Duration:
		return s, nil
	case string:
		d, err = time.ParseDuration(s)
		return
	default:
		err = fmt.Errorf("Unable to Cast %#v to Duration\n", i)
		return
	}
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:16,代码来源:caste.go

示例14: ApplyCoreConfigData

// ApplyCoreConfigData reads the table core_config_data into the Manager and overrides
// existing values. If the column value is NULL entry will be ignored.
func (m *Manager) ApplyCoreConfigData(dbrSess dbr.SessionRunner) error {
	var ccd TableCoreConfigDataSlice
	rows, err := csdb.LoadSlice(dbrSess, TableCollection, TableIndexCoreConfigData, &ccd)
	if log.IsDebug() {
		log.Debug("config.Manager.ApplyCoreConfigData", "rows", rows)
	}
	if err != nil {
		return log.Error("config.Manager.ApplyCoreConfigData.LoadSlice", "err", err)
	}

	for _, cd := range ccd {
		if cd.Value.Valid {
			// ScopeID(cd.ScopeID) because cd.ScopeID is a struct field and cannot satisfy interface ScopeIDer
			m.Write(Path(cd.Path), Scope(GetScopeGroup(cd.Scope), ScopeID(cd.ScopeID)))
		}
	}
	return nil
}
开发者ID:optimuse,项目名称:csfw,代码行数:20,代码来源:manager.go

示例15: ToTimeE

func ToTimeE(i interface{}) (tim time.Time, err error) {
	i = indirect(i)
	if log.IsDebug() {
		log.Debug("cast=ToTimeE", "type", reflect.TypeOf(i), "value", i)
	}

	switch s := i.(type) {
	case time.Time:
		return s, nil
	case string:
		d, e := StringToDate(s)
		if e == nil {
			return d, nil
		}
		return time.Time{}, fmt.Errorf("Could not parse Date/Time format: %v\n", e)
	default:
		return time.Time{}, fmt.Errorf("Unable to Cast %#v to Time\n", i)
	}
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:19,代码来源:caste.go


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