• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log.IsDebug函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了IsDebug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


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


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


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


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


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


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


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


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

func defaultAdapterErrFunc(rw http.ResponseWriter, req *http.Request, err error) {
	if log.IsDebug() {
		log.Error("ctxhttp.AdapterErrorFunc", "err", err, "req", req, "url", req.URL)
	}
	code := http.StatusBadRequest
	http.Error(rw, fmt.Sprintf(
		"%s\nApp Error: %s",
		http.StatusText(code),
		err,
	), code)
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:11,代码来源:adapter.go


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


示例14: RESTErrorHandler

// RESTErrorHandler default REST error handler ... @todo remove echo dependency
func RESTErrorHandler(err error, c *echo.Context) {
	code := http.StatusInternalServerError
	msg := http.StatusText(code)
	if he, ok := err.(*echo.HTTPError); ok {
		code = he.Code()
		msg = he.Error()
	}
	if log.IsDebug() {
		log.Error("net.RESTErrorHandler", "err", err)
	}
	msg = err.Error()

	http.Error(c.Response(), msg, code)

}
开发者ID:postfix,项目名称:csfw,代码行数:16,代码来源:rest.go


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


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


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


示例18: ToBoolE

func ToBoolE(i interface{}) (bool, error) {
	i = indirect(i)
	if log.IsDebug() {
		log.Debug("cast=ToBoolE", "type", reflect.TypeOf(i), "value", i)
	}
	switch b := i.(type) {
	case bool:
		return b, nil
	case nil:
		return false, nil
	case int:
		if i.(int) != 0 {
			return true, nil
		}
		return false, nil
	case string:
		return strconv.ParseBool(i.(string))
	default:
		return false, fmt.Errorf("Unable to Cast %#v to bool", i)
	}
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:21,代码来源:caste.go


示例19: ToSliceE

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

	var s []interface{}

	switch v := i.(type) {
	case []interface{}:
		for _, u := range v {
			s = append(s, u)
		}
		return s, nil
	case []map[string]interface{}:
		for _, u := range v {
			s = append(s, u)
		}
		return s, nil
	default:
		return s, fmt.Errorf("Unable to Cast %#v of type %v to []interface{}", i, reflect.TypeOf(i))
	}
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:23,代码来源:caste.go


示例20: ToIntE

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

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log.NewStdLogger函数代码示例发布时间:2022-05-23
下一篇:
Golang log.Error函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap