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

Golang log.Error函数代码示例

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

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



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

示例1: LoadStringEntities

// LoadStringEntities executes a SELECT query and returns a slice containing columns names and its string values
func LoadStringEntities(db *sql.DB, dbSelect *dbr.SelectBuilder, query ...string) ([]StringEntities, error) {

	qry := strings.Join(query, " ")
	var args []interface{}
	if qry == "" && dbSelect != nil {
		qry, args = dbSelect.ToSql()
	}

	rows, err := db.Query(qry, args...)
	if err != nil {
		return nil, log.Error("codegen.LoadStringEntities.Query420", "err", err)
	}
	defer rows.Close()

	columnNames, err := rows.Columns()
	if err != nil {
		return nil, log.Error("codegen.LoadStringEntities.Columns", "err", err)
	}

	ret := make([]StringEntities, 0, 2000)
	rss := newRowTransformer(columnNames)
	for rows.Next() {

		if err := rows.Scan(rss.cp...); err != nil {
			return nil, log.Error("codegen.LoadStringEntities.Scan", "err", err)
		}
		err := rss.toString()
		if err != nil {
			return nil, log.Error("codegen.LoadStringEntities.ToString", "err", err)
		}
		rss.append(&ret)
	}
	return ret, nil
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:35,代码来源:database.go


示例2: GetColumns

// GetColumns returns all columns from a table. It discards the column
// entity_type_id from some entity tables. The column attribute_model will also
// be dropped from table eav_attribute
func GetColumns(db *sql.DB, table string) (Columns, error) {
	var cols = make(Columns, 0, 200)
	rows, err := db.Query("SHOW COLUMNS FROM `" + table + "`")
	if err != nil {
		return nil, log.Error("codegen.GetColumns.Query", "err", err)
	}
	defer rows.Close()

	col := column{}
	for rows.Next() {

		err := rows.Scan(&col.Field, &col.Type, &col.Null, &col.Key, &col.Default, &col.Extra)
		if err != nil {
			return nil, log.Error("codegen.GetColumns.Scan", "err", err)
		}
		if isIgnoredColumn(table, col.Field.String) {
			continue
		}
		cols = append(cols, col)
	}
	err = rows.Err()
	if err != nil {
		return nil, log.Error("codegen.GetColumns.rows", "err", err)
	}
	return cols, nil
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:29,代码来源:database.go


示例3: GetColumns

// GetColumns returns all columns from a table. It discards the column entity_type_id from some
// entity tables.
func GetColumns(dbrSess dbr.SessionRunner, table string) (Columns, error) {
	var cols = make(Columns, 0, 100)

	sel := dbrSess.SelectBySql("SHOW COLUMNS FROM " + dbr.Quoter.Table(table))
	selSql, selArg := sel.ToSql()
	rows, err := sel.Query(selSql, selArg...)

	if err != nil {
		return nil, log.Error("csdb.GetColumns.Query", "err", err, "query", selSql, "args", selArg)
	}
	defer rows.Close()

	col := Column{}
	for rows.Next() {
		err := rows.Scan(&col.Field, &col.Type, &col.Null, &col.Key, &col.Default, &col.Extra)
		if err != nil {
			return nil, log.Error("csdb.GetColumns.Rows.Scan", "err", err, "query", selSql, "args", selArg)
		}
		cols = append(cols, col)
	}
	err = rows.Err()
	if err != nil {
		return nil, log.Error("csdb.GetColumns.Rows.Err", "err", err, "query", selSql, "args", selArg)
	}
	return cols, nil
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:28,代码来源:columns.go


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


示例5: sendMsgRecoverable

func sendMsgRecoverable(id int, sl MessageReceiver, a arg) (err error) {
	defer func() { // protect ... you'll never know
		if r := recover(); r != nil {
			if recErr, ok := r.(error); ok {
				err = log.Error("config.pubSub.publish.recover.err", "err", recErr)
			} else {
				err = log.Error("config.pubSub.publish.recover.r", "recover", r)
			}
			// the overall trick here is, that defer will assign a new error to err
			// and therefore will overwrite the returned nil value!
		}
	}()
	err = sl.MessageConfig(a.path, a.scope, a.scopeID)
	return
}
开发者ID:postfix,项目名称:csfw,代码行数:15,代码来源:manager_pubsub.go


示例6: RESTStores

// RESTStores creates a list of all stores
func RESTStores(sm *Manager) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		stores, err := sm.Stores()
		if err != nil {
			log.Error("store.RESTStores.Stores", "err", err, "req", r)
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}

		err = net.WriteJSON(w, stores)
		if err != nil {
			log.Error("store.RESTStores.WriteJSON", "err", err, "req", r)
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}
	}
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:16,代码来源:rest.go


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


示例8: ToJSON

// ToJSON returns a JSON string, convenience function.
func (s Slice) ToJSON() (string, error) {
	var buf bytes.Buffer
	if err := json.NewEncoder(&buf).Encode(s); err != nil {
		return "", log.Error("config.ValueLabelSlice.ToJSON.Encode", "err", err, "slice", s)
	}
	return buf.String(), nil
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:8,代码来源:slice.go


示例9: DefaultSwedish

// DefaultSwedish sets the global and New() defaults swedish rounding. Errors will be logged.
// http://en.wikipedia.org/wiki/Swedish_rounding
func DefaultSwedish(i Interval) {
	if i < interval999 {
		gSwedish = i
	} else {
		log.Error("money.DefaultSwedish", "err", errors.New("Interval out of scope"), "interval", i)
	}
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:9,代码来源:defaults.go


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


示例11: Authorization

// Authorization represent a middleware handler for a http router.
// For POST or PUT requests, it also parses the request body as a form. The
// claims of a token will be appended to the requests Form map. So you
// can access the token in any http/routing library.
func (a *AuthManager) Authorization(next http.Handler) http.Handler {

	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

		token, err := jwt.ParseFromRequest(r, a.keyFunc)

		var inBL bool
		if token != nil {
			inBL = a.Blacklist.Has(token.Raw)
		}
		if token != nil && err == nil && token.Valid && !inBL {
			if err := appendTokenToForm(r, token, a.PostFormVarPrefix); err != nil {
				a.HTTPErrorHandler(
					log.Error("userjwt.AuthManager.Authenticate.appendTokenToForm", "err", err, "r", r, "token", token),
				).ServeHTTP(w, r)
			} else {
				next.ServeHTTP(w, r)
			}
		} else {
			if log.IsInfo() {
				log.Info("userjwt.AuthManager.Authenticate", "err", err, "token", token, "blacklist", inBL)
			}
			a.HTTPErrorHandler(err).ServeHTTP(w, r) // is that really thread safe or other bug?
		}
	})
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:30,代码来源:manager.go


示例12: Validate

// Validate checks for duplicated configuration paths in all three hierarchy levels.
func (ss SectionSlice) Validate() error {
	if len(ss) == 0 {
		return errgo.New("SectionSlice is empty")
	}
	// @todo try to pick the right strategy between maps and slice depending on the overall size of a full SectionSlice
	var pc = make(utils.StringSlice, ss.TotalFields()) // pc path checker
	i := 0
	for _, s := range ss {
		for _, g := range s.Groups {
			for _, f := range g.Fields {
				arg, err := newArg(Path(s.ID, g.ID, f.ID))
				if err != nil {
					log.Error("config.SectionSlice.Validate.newArg", "err", err, "s", s, "g", g, "f", f)
				}
				p := arg.scopePath()
				if pc.Include(p) {
					return errgo.Newf("Duplicate entry for path %s :: %s", p, ss.ToJSON())
				}
				pc[i] = p
				i++
			}
		}
	}
	return nil
}
开发者ID:postfix,项目名称:csfw,代码行数:26,代码来源:elements_section.go


示例13: GetEavValueTables

// GetEavValueTables returns a map of all custom and default EAV value tables for entity type codes.
// Despite value_table_prefix can have in Magento a different table name we treat it here
// as the table name itself. Not thread safe.
func GetEavValueTables(dbrConn *dbr.Connection, entityTypeCodes []string) (TypeCodeValueTable, error) {

	typeCodeTables := make(TypeCodeValueTable, len(entityTypeCodes))

	for _, typeCode := range entityTypeCodes {

		vtp, err := dbrConn.NewSession().
			Select("`value_table_prefix`").
			From(TablePrefix+TableEavEntityType).
			Where("`value_table_prefix` IS NOT NULL").
			Where("`entity_type_code` = ?", typeCode).
			ReturnString()

		if err != nil && err != dbr.ErrNotFound {
			return nil, log.Error("codegen.GetEavValueTables.select", "err", err)
		}
		if vtp == "" {
			vtp = typeCode + TableNameSeparator + TableEntityTypeSuffix + TableNameSeparator // e.g. catalog_product_entity_
		} else {
			vtp = vtp + TableNameSeparator
		}

		tableNames, err := GetTables(dbrConn.NewSession(), vtp+`%`)
		if err != nil {
			return nil, log.Error("codegen.GetEavValueTables.GetTables", "err", err)
		}

		if _, ok := typeCodeTables[typeCode]; !ok {
			typeCodeTables[typeCode] = make(map[string]string, len(tableNames))
		}
		for _, t := range tableNames {
			valueSuffix := t[len(vtp):]
			if TableEntityTypeValueSuffixes.contains(valueSuffix) {
				/*
				   other tables like catalog_product_entity_gallery, catalog_product_entity_group_price,
				   catalog_product_entity_tier_price, etc are the backend model tables for different storage systems.
				   they are not part of the default EAV model.
				*/
				typeCodeTables[typeCode][t] = valueSuffix
			}

		}

	}

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


示例14: ToJSON

// ToJSON transforms the whole slice into JSON
func (gs GroupSlice) ToJSON() string {
	var buf bytes.Buffer
	if err := json.NewEncoder(&buf).Encode(gs); err != nil {
		log.Error("config.GroupSlice.ToJSON.Encode", "err", err)
		return ""
	}
	return buf.String()
}
开发者ID:optimuse,项目名称:csfw,代码行数:9,代码来源:elements_group.go


示例15: ToJSON

// ToJSON returns a JSON string
func (s ValueLabelSlice) ToJSON() string {
	var buf bytes.Buffer
	if err := json.NewEncoder(&buf).Encode(s); err != nil {
		log.Error("ValueLabelSlice=ToJSON", "err", err)
		return ""
	}
	return buf.String()
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:9,代码来源:elements_field_models.go


示例16: GetDateTime

// GetDateTime returns a date and time object from the manager. Example usage see GetString.
func (m *Manager) GetDateTime(o ...ArgFunc) time.Time {
	vs := m.get(o...)
	t, err := cast.ToTimeE(vs)
	if err != nil {
		log.Error("config.Manager.GetDateTime.ToTimeE", "err", err, "val", vs)
	}
	return t
}
开发者ID:optimuse,项目名称:csfw,代码行数:9,代码来源:manager.go


示例17: mustNewArg

// mustNewArg panics on error. useful for initialization process
func mustNewArg(opts ...ArgFunc) arg {
	a, err := newArg(opts...)
	if err != nil {
		log.Error("config.mustNewArg", "err", err)
		panic(err)
	}
	return a
}
开发者ID:postfix,项目名称:csfw,代码行数:9,代码来源:argument.go


示例18: IsSet

// IsSet checks if a key is in the config. Does not bubble. Returns false on error.
func (m *Manager) IsSet(o ...ArgFunc) bool {
	a, err := newArg(o...)
	if err != nil {
		log.Error("config.Manager.IsSet.newArg", "err", err)
		return false
	}
	return m.v.IsSet(a.scopePath())
}
开发者ID:optimuse,项目名称:csfw,代码行数:9,代码来源:manager.go


示例19: NewSourceCurrencyAll

// NewSourceCurrencyAll creates a new option for all currencies. If one argument of
// the ModelConstructor has been provided you may skip the calling of Construct().
func NewSourceCurrencyAll(mc ...config.ModelConstructor) *SourceCurrencyAll {
	sca := &SourceCurrencyAll{}
	if len(mc) == 1 {
		if err := sca.Construct(mc[0]); err != nil {
			log.Error("directory.NewSourceCurrencyAll.Construct", "err", err)
		}
	}
	return sca
}
开发者ID:postfix,项目名称:csfw,代码行数:11,代码来源:source_models.go


示例20: sendMessages

func sendMessages(subs map[int]MessageReceiver, a arg) (evict []int) {
	for id, s := range subs {
		if err := sendMsgRecoverable(id, s, a); err != nil {
			log.Error("config.pubSub.publish.sendMessages", "err", err, "id", id)
			evict = append(evict, id) // mark Subscribers for removal which failed ...
		}
	}
	return
}
开发者ID:postfix,项目名称:csfw,代码行数:9,代码来源:manager_pubsub.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang log.IsDebug函数代码示例发布时间:2022-05-23
下一篇:
Golang log.Debug函数代码示例发布时间: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