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


Golang Logger.Error方法代码示例

本文整理汇总了Golang中github.com/docker/distribution/context.Logger.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Error方法的具体用法?Golang Logger.Error怎么用?Golang Logger.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/docker/distribution/context.Logger的用法示例。


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

示例1: changefeed

func changefeed(logger ctxu.Logger, store storage.MetaStore, imageName, changeID string, records int64) ([]byte, error) {
	changes, err := store.GetChanges(changeID, int(records), imageName)
	if err != nil {
		logger.Errorf("500 GET could not retrieve records: %s", err.Error())
		return nil, errors.ErrUnknown.WithDetail(err)
	}
	out, err := json.Marshal(&changefeedResponse{
		NumberOfRecords: len(changes),
		Records:         changes,
	})
	if err != nil {
		logger.Error("500 GET could not json.Marshal changefeedResponse")
		return nil, errors.ErrUnknown.WithDetail(err)
	}
	return out, nil
}
开发者ID:endophage,项目名称:notary,代码行数:16,代码来源:changefeed.go

示例2: serveError

func serveError(log ctxu.Logger, w http.ResponseWriter, err error) {
	if httpErr, ok := err.(errcode.Error); ok {
		// info level logging for non-5XX http errors
		httpErrCode := httpErr.ErrorCode().Descriptor().HTTPStatusCode
		if httpErrCode >= http.StatusInternalServerError {
			// error level logging for 5XX http errors
			log.Errorf("%s: %s: %v", httpErr.ErrorCode().Error(), httpErr.Message, httpErr.Detail)
		} else {
			log.Infof("%s: %s: %v", httpErr.ErrorCode().Error(), httpErr.Message, httpErr.Detail)
		}
	}
	e := errcode.ServeJSON(w, err)
	if e != nil {
		log.Error(e)
	}
	return
}
开发者ID:jfrazelle,项目名称:notary,代码行数:17,代码来源:http.go

示例3: checkChangefeedInputs

func checkChangefeedInputs(logger ctxu.Logger, s interface{}, r string) (
	store storage.MetaStore, pageSize int64, err error) {

	store, ok := s.(storage.MetaStore)
	if !ok {
		logger.Error("500 GET unable to retrieve storage")
		err = errors.ErrNoStorage.WithDetail(nil)
		return
	}
	pageSize, err = strconv.ParseInt(r, 10, 32)
	if err != nil {
		logger.Errorf("400 GET invalid pageSize: %s", r)
		err = errors.ErrInvalidParams.WithDetail(
			fmt.Sprintf("invalid records parameter: %s", err.Error()),
		)
		return
	}
	if pageSize == 0 {
		pageSize = notary.DefaultPageSize
	}
	return
}
开发者ID:endophage,项目名称:notary,代码行数:22,代码来源:changefeed.go

示例4: getSnapshot

// getTimestampHandler returns a timestamp.json given a GUN
func getSnapshot(ctx context.Context, w http.ResponseWriter, logger ctxu.Logger, store storage.MetaStore, gun string) error {
	cryptoServiceVal := ctx.Value("cryptoService")
	cryptoService, ok := cryptoServiceVal.(signed.CryptoService)
	if !ok {
		return errors.ErrNoCryptoService.WithDetail(nil)
	}

	out, err := snapshot.GetOrCreateSnapshot(gun, store, cryptoService)
	if err != nil {
		switch err.(type) {
		case *storage.ErrNoKey, storage.ErrNotFound:
			logger.Error("404 GET snapshot")
			return errors.ErrMetadataNotFound.WithDetail(nil)
		default:
			logger.Error("500 GET snapshot")
			return errors.ErrUnknown.WithDetail(err)
		}
	}

	logger.Debug("200 GET snapshot")
	w.Write(out)
	return nil
}
开发者ID:useidel,项目名称:notary,代码行数:24,代码来源:default.go


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