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

Golang log.Debugf函数代码示例

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

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



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

示例1: ResetPassword

// ResetPassword resets a password of user.
func ResetPassword(c *gin.Context) (int, error) {
	var user model.User
	var passwordResetForm PasswordResetForm
	c.BindWith(&passwordResetForm, binding.Form)
	if db.ORM.Where(&model.User{PasswordResetToken: passwordResetForm.PasswordResetToken}).First(&user).RecordNotFound() {
		return http.StatusNotFound, errors.New("User is not found.")
	}
	isExpired := timeHelper.IsExpired(user.PasswordResetUntil)
	log.Debugf("passwordResetUntil : %s", user.PasswordResetUntil.UTC())
	log.Debugf("expired : %t", isExpired)
	if isExpired {
		return http.StatusForbidden, errors.New("token not valid.")
	}
	newPassword, err := bcrypt.GenerateFromPassword([]byte(passwordResetForm.Password), 10)
	if err != nil {
		return http.StatusInternalServerError, errors.New("User is not updated. Password not Generated.")
	}
	passwordResetForm.Password = string(newPassword)
	log.Debugf("user password before : %s ", user.Password)
	modelHelper.AssignValue(&user, &passwordResetForm)
	user.PasswordResetToken = ""
	user.PasswordResetUntil = time.Now()
	log.Debugf("user password after : %s ", user.Password)
	status, err := UpdateUserCore(&user)
	if err != nil {
		return status, err
	}
	status, err = SetCookie(c, user.Token)
	return status, err
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:31,代码来源:password.go


示例2: CreateFiles

// CreateFiles creates files.
func CreateFiles(c *gin.Context) (int, error) {
	var forms FilesForm
	start := time.Now()
	c.BindWith(&forms, binding.JSON)
	log.Debugf("CreateFiles c form : %v", forms)

	user, _ := userService.CurrentUser(c)
	sqlStrBuffer := new(bytes.Buffer)
	stringHelper.Concat(sqlStrBuffer, "INSERT INTO file(user_id, name, size, created_at) VALUES ")
	values := []interface{}{}
	for _, file := range forms.Files {
		stringHelper.Concat(sqlStrBuffer, "(?, ?, ?, ?),")
		values = append(values, user.Id, file.Name, file.Size, time.Now())

	}
	// sqlStrBuffer.Truncate(sqlStrBuffer.Len() - 1) is slower than slice.
	if len(values) > 0 {
		sqlStr := sqlStrBuffer.String()
		sqlStr = sqlStr[0 : len(sqlStr)-1]
		log.Debugf("sqlStr for File : %s", sqlStr)
		db.ORM.Exec(sqlStr, values...)
		elapsed := time.Since(start)
		log.Debugf("CreateFiles elapsed : %s", elapsed)
	}

	return http.StatusCreated, nil
}
开发者ID:tka,项目名称:goyangi,代码行数:28,代码来源:file.go


示例3: SendPasswordResetToken

// SendPasswordResetToken sends a password reset token.
func SendPasswordResetToken(c *gin.Context) (int, error) {
	var user model.User
	var sendPasswordResetForm SendPasswordResetForm
	var err error
	log.Debugf("c.Params : %v", c.Params)
	c.BindWith(&sendPasswordResetForm, binding.Form)
	if db.ORM.Where(&model.User{Email: sendPasswordResetForm.Email}).First(&user).RecordNotFound() {
		return http.StatusNotFound, errors.New("User is not found. Please Check the email.")
	}
	user.PasswordResetUntil = timeHelper.TwentyFourHoursLater()
	user.PasswordResetToken, err = crypto.GenerateRandomToken16()
	if err != nil {
		return http.StatusInternalServerError, err
	}
	log.Debugf("generated token : %s", user.PasswordResetToken)
	status, err := UpdateUserCore(&user)
	if err != nil {
		return status, err
	}
	err = SendEmailPasswordResetToken(user.Email, user.PasswordResetToken, "en-us")
	if err != nil {
		return http.StatusInternalServerError, err
	}
	return http.StatusOK, nil
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:26,代码来源:password.go


示例4: RetrieveLocations

// RetrieveLocations retrieves locations.
func RetrieveLocations(c *gin.Context) ([]model.Location, bool, int, bool, bool, int, error) {
	var locations []model.Location
	var locationCount, locationPerPage int
	filterQuery := c.Request.URL.Query().Get("filter")
	locationPerPage = config.LocationPerPage
	filter := &LocationFilter{}
	whereBuffer := new(bytes.Buffer)
	whereValues := []interface{}{}
	if len(filterQuery) > 0 {
		log.Debugf("retrieve Locations filter : %s\n", filterQuery)
		json.Unmarshal([]byte(filterQuery), &filter)
		if filter.UserId > 0 {
			stringHelper.Concat(whereBuffer, "user_id = ?")
			whereValues = append(whereValues, filter.UserId)
			log.Debugf("userId : %d\n", filter.UserId)
		}
		if filter.LocationPerPage > 0 {
			locationPerPage = filter.LocationPerPage
			log.Debugf("locationPerPage : %d\n", filter.LocationPerPage)
		}
	} else {
		log.Debug("no filters found.\n")
	}
	log.Debugf("filterQuery %v.\n", filterQuery)
	log.Debugf("filter %v.\n", filter)
	whereStr := whereBuffer.String()
	db.ORM.Model(model.Location{}).Where(whereStr, whereValues...).Count(&locationCount)
	offset, currentPage, hasPrev, hasNext := pagination.Paginate(filter.CurrentPage, locationPerPage, locationCount)
	db.ORM.Limit(locationPerPage).Offset(offset).Order(config.LocationOrder).Where(whereStr, whereValues...).Find(&locations)

	return locations, canUserWrite(c), currentPage, hasPrev, hasNext, http.StatusOK, nil
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:33,代码来源:location.go


示例5: LoginOrCreateOauthUser

// LoginOrCreateOauthUser login or create with oauthUser
func LoginOrCreateOauthUser(c *gin.Context, oauthUser *OauthUser, providerID int64, token *oauth2.Token) (int, error) {
	var connection model.Connection
	var count int
	db.ORM.Where("provider_id = ? and provider_user_id = ?", providerID, oauthUser.Id).First(&connection).Count(&count)

	connection.ProviderId = providerID
	connection.ProviderUserId = oauthUser.Id
	connection.AccessToken = token.AccessToken
	connection.ProfileUrl = oauthUser.ProfileUrl
	connection.ImageUrl = oauthUser.ImageUrl
	log.Debugf("connection count : %v", count)
	if count == 1 {
		var user model.User
		if db.ORM.First(&user, "id = ?", connection.UserId).RecordNotFound() {
			return http.StatusNotFound, errors.New("User is not found.")
		}
		log.Debugf("user : %v", user)
		if db.ORM.Save(&connection).Error != nil {
			return http.StatusInternalServerError, errors.New("Connection is not updated.")
		}
		status, err := LoginWithOauthUser(c, user.Token)
		return status, err
	}
	log.Debugf("Connection is not exist.")
	user, status, err := CreateOauthUser(c, oauthUser, &connection)
	if err != nil {
		return status, err
	}
	status, err = LoginWithOauthUser(c, user.Token)
	return status, err
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:32,代码来源:common.go


示例6: OauthGithub

// OauthGithub link connection and user.
func OauthGithub(c *gin.Context) (int, error) {
	var authResponse oauth2.AuthResponse
	var oauthUser OauthUser
	c.BindWith(&authResponse, binding.Form)
	log.Debugf("oauthRedirect form: %v", authResponse)
	response, token, err := oauth2.OauthRequest(github.RequestURL, github.Config, authResponse)
	if err != nil {
		log.Error("get response error")
		return http.StatusInternalServerError, err
	}
	githubUser, err := SetGithubUser(response)
	if err != nil {
		log.Error("SetGithubUser error")
		return http.StatusInternalServerError, err
	}
	modelHelper.AssignValue(&oauthUser, githubUser)
	oauthUser.Id = strconv.Itoa(githubUser.UserId)
	log.Debugf("\noauthUser item : %v", oauthUser)
	status, err := LoginOrCreateOauthUser(c, &oauthUser, github.ProviderId, token)
	if err != nil {
		log.Errorf("LoginOrCreateOauthUser error: %d", status)
		return status, err
	}
	return http.StatusSeeOther, nil
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:26,代码来源:github.go


示例7: RetrieveArticle

// RetrieveArticle retrieve an article.
func RetrieveArticle(c *gin.Context) (model.Article, bool, int64, int, error) {
	var article model.Article
	var count int
	var currentUserId int64
	var isAuthor bool
	id := c.Params.ByName("id")
	if db.ORM.First(&article, "id = ?", id).RecordNotFound() {
		return article, isAuthor, currentUserId, http.StatusNotFound, errors.New("Article is not found.")
	}
	log.Debugf("Article : %s\n", article)
	log.Debugf("Count : %s\n", count)
	currentUser, err := userService.CurrentUser(c)
	if err == nil {
		currentUserId = currentUser.Id
		isAuthor = currentUser.Id == article.UserId
	}

	assignRelatedUser(&article)
	var commentList model.CommentList
	comments, currentPage, hasPrev, hasNext, _ := commentService.RetrieveComments(article)
	commentList.Comments = comments
	commentService.SetCommentPageMeta(&commentList, currentPage, hasPrev, hasNext, article.CommentCount)
	article.CommentList = commentList
	var likingList model.LikingList
	likings, currentPage, hasPrev, hasNext, _ := likingRetriever.RetrieveLikings(article)
	likingList.Likings = likings
	currentUserlikedCount := db.ORM.Model(&article).Where("id =?", currentUserId).Association("Likings").Count()
	log.Debugf("Current user like count : %d", currentUserlikedCount)
	likingMeta.SetLikingPageMeta(&likingList, currentPage, hasPrev, hasNext, article.LikingCount, currentUserlikedCount)
	article.LikingList = likingList
	return article, isAuthor, currentUserId, http.StatusOK, nil
}
开发者ID:tka,项目名称:goyangi,代码行数:33,代码来源:article.go


示例8: RetrieveOauthStatus

// RetrieveOauthStatus retrieves ouath status that provider connected or not.
func RetrieveOauthStatus(c *gin.Context) (oauthStatusMap, int, error) {
	var oauthStatus oauthStatusMap
	var connections []model.Connection
	oauthStatus = make(oauthStatusMap)
	currentUser, err := userService.CurrentUser(c)
	if err != nil {
		return oauthStatus, http.StatusUnauthorized, err
	}
	db.ORM.Model(&currentUser).Association("Connections").Find(&connections)
	for _, connection := range connections {
		log.Debugf("connection.ProviderId : %d", connection.ProviderId)
		switch connection.ProviderId {
		case google.ProviderId:
			oauthStatus["google"] = true
		case github.ProviderId:
			oauthStatus["github"] = true
		case yahoo.ProviderId:
			oauthStatus["yahoo"] = true
		case facebook.ProviderId:
			oauthStatus["facebook"] = true
		case twitter.ProviderId:
			oauthStatus["twitter"] = true
		case linkedin.ProviderId:
			oauthStatus["linkedin"] = true
		case kakao.ProviderId:
			oauthStatus["kakao"] = true
		case naver.ProviderId:
			oauthStatus["naver"] = true
		}
	}
	log.Debugf("oauthStatus : %v", oauthStatus)
	return oauthStatus, http.StatusOK, nil
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:34,代码来源:common.go


示例9: EmailVerification

// EmailVerification verifies an email of user.
func EmailVerification(c *gin.Context) (int, error) {
	var user model.User
	var verifyEmailForm VerifyEmailForm
	c.BindWith(&verifyEmailForm, binding.Form)
	log.Debugf("verifyEmailForm.ActivationToken : %s", verifyEmailForm.ActivationToken)
	if db.ORM.Where(&model.User{ActivationToken: verifyEmailForm.ActivationToken}).First(&user).RecordNotFound() {
		return http.StatusNotFound, errors.New("User is not found.")
	}
	isExpired := timeHelper.IsExpired(user.ActivateUntil)
	log.Debugf("passwordResetUntil : %s", user.ActivateUntil.UTC())
	log.Debugf("expired : %t", isExpired)
	if isExpired {
		return http.StatusForbidden, errors.New("token not valid.")
	}
	user.ActivationToken = ""
	user.ActivateUntil = time.Now()
	user.ActivatedAt = time.Now()
	user.Activation = true
	status, err := UpdateUserCore(&user)
	if err != nil {
		return status, err
	}
	status, err = SetCookie(c, user.Token)
	return status, err
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:26,代码来源:verification.go


示例10: FewDurationLater

func FewDurationLater(duration time.Duration) time.Time {
	// When Save time should considering UTC
	baseTime := time.Now()
	log.Debugf("basetime : %s", baseTime)
	fewDurationLater := baseTime.Add(duration)
	log.Debugf("time : %s", fewDurationLater)
	return fewDurationLater
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:8,代码来源:timeHelper.go


示例11: RegisterHanderFromForm

// RegisterHanderFromForm sets cookie from a RegistrationForm.
func RegisterHanderFromForm(c *gin.Context, registrationForm RegistrationForm) (int, error) {
	email := registrationForm.Email
	pass := registrationForm.Password
	log.Debugf("RegisterHandler UserEmail : %s", email)
	log.Debugf("RegisterHandler UserPassword : %s", pass)
	status, err := SetCookieHandler(c, email, pass)
	return status, err
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:9,代码来源:cookie.go


示例12: IsExpired

func IsExpired(expirationTime time.Time) bool {
	baseTime := time.Now()
	log.Debugf("basetime : %s", baseTime)
	log.Debugf("expirationTime : %s", expirationTime)
	elapsed := time.Since(expirationTime)
	log.Debugf("elapsed : %s", elapsed)
	after := time.Now().After(expirationTime)
	log.Debugf("after : %t", after)
	return after
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:10,代码来源:timeHelper.go


示例13: SetNaverUser

// SetNaverUser set naver user.
func SetNaverUser(response *http.Response) (*NaverUser, error) {
	naverUser := &NaverUser{}
	defer response.Body.Close()
	log.Debugf("response.Body: %v\n", response.Body)
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return naverUser, err
	}
	json.Unmarshal(body, &naverUser)
	log.Debugf("\nnaverUser: %v\n", naverUser)
	return naverUser, err
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:13,代码来源:naver.go


示例14: SetKakaoUser

// SetKakaoUser set kakao user.
func SetKakaoUser(response *http.Response) (*KakaoUser, error) {
	kakaoUser := &KakaoUser{}
	defer response.Body.Close()

	log.Debugf("response.Body: %v\n", response.Body)
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return kakaoUser, err
	}
	json.Unmarshal(body, &kakaoUser)
	log.Debugf("\nkakaoUser: %v\n", kakaoUser)
	return kakaoUser, err
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:14,代码来源:kakao.go


示例15: imageUploader

// imageUploader is a uploader that uploading files.
func imageUploader() concurrency.ConcurrencyManager {
	return func(reader *multipart.Reader) concurrency.Result {
		atomic.AddInt32(concurrency.BusyWorker, 1)
		var result concurrency.Result
		result.Code = http.StatusOK
		for {
			part, err := reader.NextPart()

			uploadedNow := atomic.AddUint32(concurrency.Done, 1)
			log.Debugf("count %d", uploadedNow)
			if err == io.EOF {
				log.Debug("End of file.")
				break
			}
			if part.FileName() == "" {
				log.Debug("File name is empty.")
				continue
			}
			err = upload.UploadImageFile(s3UploadPath, part)
			if err != nil {
				log.Error("Image uploading failed. : " + err.Error())
				result.Code = http.StatusBadRequest
				result.Error = err
				return result
			}
			log.Debug("File uploaded.")
		}
		log.Debug("Iteration concurrency.Done.")
		return result
	}
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:32,代码来源:image.go


示例16: RetrieveLikingsOnArticles

// RetrieveLikingsOnArticles retrieves likings on article.
func RetrieveLikingsOnArticles(c *gin.Context) ([]model.User, int, bool, bool, int, int, error) {
	var article model.Article
	var likings []model.User
	var retrieveListForm form.RetrieveListForm
	var hasPrev, hasNext bool
	var currentPage, count int
	articleId := c.Params.ByName("id")
	log.Debugf("Liking params : %v", c.Params)
	c.BindWith(&retrieveListForm, binding.Form)
	log.Debugf("retrieveListForm %+v\n", retrieveListForm)
	if db.ORM.First(&article, articleId).RecordNotFound() {
		return likings, currentPage, hasPrev, hasNext, count, http.StatusNotFound, errors.New("Article is not found.")
	}
	likings, currentPage, hasPrev, hasNext, count = likingRetriever.RetrieveLikings(article, retrieveListForm.CurrentPage)
	return likings, currentPage, hasPrev, hasNext, count, http.StatusOK, nil
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:17,代码来源:liking.go


示例17: RetrieveLikingsOnLocations

// RetrieveLikingsOnLocations retrieves likings on location.
func RetrieveLikingsOnLocations(c *gin.Context) ([]*model.PublicUser, int, bool, bool, int, int, error) {
	var location model.Location
	var likings []*model.PublicUser
	var retrieveListForm form.RetrieveListForm
	var hasPrev, hasNext bool
	var currentPage, count int
	locationId := c.Params.ByName("id")
	log.Debugf("Liking params : %v", c.Params)
	c.BindWith(&retrieveListForm, binding.Form)
	log.Debugf("retrieveListForm %+v\n", retrieveListForm)
	if db.ORM.First(&location, locationId).RecordNotFound() {
		return likings, currentPage, hasPrev, hasNext, count, http.StatusNotFound, errors.New("Location is not found.")
	}
	likings, currentPage, hasPrev, hasNext, count = likingRetriever.RetrieveLikings(location, retrieveListForm.CurrentPage)
	return likings, currentPage, hasPrev, hasNext, count, http.StatusOK, nil
}
开发者ID:tka,项目名称:goyangi,代码行数:17,代码来源:liking.go


示例18: RetrieveUser

// RetrieveUser retrieves a user.
func RetrieveUser(c *gin.Context) (*model.PublicUser, bool, int64, int, error) {
	var user model.User
	var currentUserId int64
	var isAuthor bool
	// var publicUser *model.PublicUser
	// publicUser.User = &user
	id := c.Params.ByName("id")
	if db.ORM.Select(config.UserPublicFields).First(&user, id).RecordNotFound() {
		return &model.PublicUser{User: &user}, isAuthor, currentUserId, http.StatusNotFound, errors.New("User is not found.")
	}
	currentUser, err := CurrentUser(c)
	if err == nil {
		currentUserId = currentUser.Id
		isAuthor = currentUser.Id == user.Id
	}
	var likingList model.LikingList
	likings, currentPage, hasPrev, hasNext, _ := likingRetriever.RetrieveLikings(user)
	likingList.Likings = likings
	currentUserlikedCount := db.ORM.Model(&user).Where("id =?", currentUserId).Association("Likings").Count()
	log.Debugf("Current user like count : %d", currentUserlikedCount)
	likingMeta.SetLikingPageMeta(&likingList, currentPage, hasPrev, hasNext, user.LikingCount, currentUserlikedCount)
	user.LikingList = likingList
	var likedList model.LikedList
	liked, currentPage, hasPrev, hasNext, _ := likingRetriever.RetrieveLiked(user)
	likedList.Liked = liked
	likingMeta.SetLikedPageMeta(&likedList, currentPage, hasPrev, hasNext, user.LikedCount)
	user.LikedList = likedList
	return &model.PublicUser{User: &user}, isAuthor, currentUserId, http.StatusOK, nil
}
开发者ID:wangmingjob,项目名称:goyangi,代码行数:30,代码来源:user.go


示例19: Upload

// Upload uploads file to a storage.
func Upload(reader *multipart.Reader, kind int) {
	c := make(chan UploadStatus)
	switch kind {
	case KindUploaderBasic:
		go func() {
			c <- UploadAgent(reader, 업로더, BasicUploader, Cargador, Shàngchuán, загрузчик)
		}()
	case KindUploaderArticle:
		go func() {
			c <- UploadAgent(reader, Article업로더, ArticleUploader, ArticleCargador, ArticleShàngchuán, Articleзагрузчик)
		}()
	default:
		go func() {
			c <- UploadAgent(reader, 업로더, BasicUploader, Cargador, Shàngchuán, загрузчик)
		}()
	}

	timeout := time.After(config.UploadTimeout)
	select {
	case <-c:
		workingNow := atomic.AddInt32(workingUploader, -1)
		log.Debugf("All files are uploaded. Working uploader count : %d", workingNow)
		return
	case <-timeout:
		fmt.Println("timed out")
		return
	}
}
开发者ID:tka,项目名称:goyangi,代码行数:29,代码来源:upload.go


示例20: DeleteFile

// DeleteFile deletes a file.
func DeleteFile(c *gin.Context) (int, error) {
	log.Debug("deleteFile performed")
	var targetFile model.File
	id := c.Params.ByName("id")
	if db.ORM.First(&targetFile, id).RecordNotFound() {
		return http.StatusNotFound, errors.New("File is not found.")
	}
	status, err := userPermission.CurrentUserIdentical(c, targetFile.UserId)
	if err != nil {
		return status, err
	}
	switch config.UploadTarget {
	case "S3":
		s3UploadPath := config.UploadS3Path + strconv.FormatInt(targetFile.UserId, 10) + "/"
		log.Debugf("s3UploadPath %s", s3UploadPath)
		err = aws.DelFromMyBucket(s3UploadPath, targetFile.Name)
		if err != nil {
			return http.StatusInternalServerError, err
		}
	case "LOCAL":
		err = file.DeleteLocal(targetFile.Name)
		if err != nil {
			return http.StatusInternalServerError, err
		}
	}

	if db.ORM.Delete(&targetFile).Delete(targetFile).Error != nil {
		return http.StatusInternalServerError, errors.New("File is not deleted.")
	}
	return http.StatusOK, nil
}
开发者ID:tka,项目名称:goyangi,代码行数:32,代码来源:file.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang dialog_ui.DialogUi类代码示例发布时间:2022-05-23
下一篇:
Golang model.User类代码示例发布时间: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