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

Golang log.Debugf函数代码示例

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

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



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

示例1: UpdateAllPortfoliosAndAlert

func UpdateAllPortfoliosAndAlert(w http.ResponseWriter, r *http.Request) {
	ctx := appengine.NewContext(r)
	if len(cachedStocks) == 0 {
		log.Debugf(ctx, "UpdateAllPortfoliosAndAlert: cachedStocks are empty")
		return
	}
	if !isWeekDay() {
		log.Debugf(ctx, "UpdateAllPortfoliosAndAlert: is not a weekday.")
		return
	}
	defer func() { isUpdateInProgress = false }()
	isUpdateInProgress = true

	var portfolioStocks []PortfolioStock
	if err := GetAllEntities(ctx, "PortfolioStock", &portfolioStocks); err != nil {
		log.Debugf(ctx, "UpdateAllPortfoliosAndAlert: Could not fetch all portfolios ", err)
		return
	}
	if len(portfolioStocks) == 0 {
		log.Debugf(ctx, "UpdateAllPortfoliosAndAlert: fetched portfoilios len is 0")
		return
	}
	//	log.Debugf(ctx,"Before filteting eligible stocks ", Jsonify(portfolioStocks))
	eligibleStocks := FilterForAlertEligiblePortfolioStocks(ctx, portfolioStocks)
	//	log.Debugf(ctx,"After filteting eligible stocks ", Jsonify(portfolioStocks))
	SendAlerts(ctx, eligibleStocks)
}
开发者ID:newtechfellas,项目名称:StockAlerts,代码行数:27,代码来源:scheduler.go


示例2: writeLogStorage

func (sink *LogSink) writeLogStorage(r *wcg.LogRecord) error {
	c := sink.ctx
	formatter := sink.formatter
	if c == nil {
		c = NewContext(r.Request)
	}
	var text string
	if r.SourceStack != nil && len(r.SourceStack) > 0 {
		text = fmt.Sprintf(
			"%s\n-- Stack Trace --\n%s",
			string(formatter.Format(r)),
			strings.Join(r.SourceStack, "\n"),
		)
	} else {
		text = string(formatter.Format(r))
	}

	switch r.Level {
	case wcg.LogLevelTrace:
		log.Debugf(c, "%s", text) // app engine does not support trace level
	case wcg.LogLevelDebug:
		log.Debugf(c, "%s", text)
	case wcg.LogLevelInfo:
		log.Infof(c, "%s", text)
	case wcg.LogLevelWarn:
		log.Warningf(c, "%s", text)
	case wcg.LogLevelError:
		log.Errorf(c, "%s", text)
	case wcg.LogLevelFatal:
		log.Criticalf(c, "%s", text)
	default:
		// nothing
	}
	return nil
}
开发者ID:speedland,项目名称:service,代码行数:35,代码来源:logger.go


示例3: ajaxAboutAllIdioms

func ajaxAboutAllIdioms(w http.ResponseWriter, r *http.Request) error {
	c := appengine.NewContext(r)

	log.Debugf(c, "retrieveAllIdioms start...")
	allIdioms, err := retrieveAllIdioms(r)
	if err != nil {
		return err
	}
	log.Debugf(c, "retrieveAllIdioms end.")

	data := AboutFacade{
		PageMeta: PageMeta{
			Toggles: toggles,
		},
		UserProfile: readUserProfile(r),
		AllIdioms:   allIdioms,
	}

	log.Debugf(c, "block-about-all-idioms templating start...")
	if err := templates.ExecuteTemplate(w, "block-about-all-idioms", data); err != nil {
		return PiError{err.Error(), http.StatusInternalServerError}
	}
	log.Debugf(c, "block-about-all-idioms templating end.")
	return nil
}
开发者ID:Deleplace,项目名称:programming-idioms,代码行数:25,代码来源:about.go


示例4: handlePostMessage

func (api *API) handlePostMessage(res http.ResponseWriter, req *http.Request) error {
	ctx := appengine.NewContext(req)
	// handle incoming messages, send them out to everyone
	type Post struct {
		Text string
	}
	var post Post
	//	post := struct{
	//	Text string
	//	}{}
	err := json.NewDecoder(req.Body).Decode(&post)
	if err != nil {
		return err
	}
	log.Debugf(ctx, "the post is %s", post.Text)

	query := datastore.NewQuery("connections")
	it := query.Run(ctx)
	for {
		var connection struct{ Email string }
		_, err := it.Next(&connection)
		if err == datastore.Done {
			break
		} else if err != nil {
			return err
		}
		log.Debugf(ctx, "here is the email %s", connection.Email)
		err = channel.SendJSON(ctx, connection.Email, post)
		if err != nil {
			return err
		}
	}
	return nil
}
开发者ID:kaveenherath,项目名称:SummerBootCamp,代码行数:34,代码来源:handlers.go


示例5: CurrentUser

// CurrentUser checks for both JWT and Bearer tokens.
//
// It first tries to decode and verify JWT token (if conditions are met)
// and falls back to Bearer token.
//
// The returned user will have only ID, Email and ClientID fields set.
// User.ID is a Google Account ID, which is different from GAE user ID.
// For more info on User.ID see 'sub' claim description on
// https://developers.google.com/identity/protocols/OpenIDConnect#obtainuserinfo
func CurrentUser(c context.Context, scopes []string, audiences []string, clientIDs []string) (*user.User, error) {
	// The user hasn't provided any information to allow us to parse either
	// an ID token or a Bearer token.
	if len(scopes) == 0 && len(audiences) == 0 && len(clientIDs) == 0 {
		return nil, errors.New("no client ID or scope info provided.")
	}
	r := HTTPRequest(c)
	if r == nil {
		return nil, errNoRequest
	}

	token := parseToken(r)
	if token == "" {
		return nil, errors.New("No token in the current context.")
	}

	// If the only scope is the email scope, check an ID token. Alternatively,
	// we dould check if token starts with "ya29." or "1/" to decide that it
	// is a Bearer token. This is what is done in Java.
	if len(scopes) == 1 && scopes[0] == EmailScope && len(clientIDs) > 0 {
		log.Debugf(c, "Checking for ID token.")
		now := currentUTC().Unix()
		u, err := currentIDTokenUser(c, token, audiences, clientIDs, now)
		// Only return in case of success, else pass along and try
		// parsing Bearer token.
		if err == nil {
			return u, err
		}
	}

	log.Debugf(c, "Checking for Bearer token.")
	return CurrentBearerTokenUser(c, scopes, clientIDs)
}
开发者ID:davars,项目名称:go-endpoints,代码行数:42,代码来源:auth.go


示例6: buildSlackJSON

// buildSlackJSON returns a public or private Slack JSON response as a byte slice.
// Context is passed in for logging.
func buildSlackJSON(ctx context.Context, text string, isPublic bool) ([]byte, error) {
	// JustinResponse is a response we send back to Slack
	type JustinResponse struct {
		ResponseType string `json:"response_type"` // "ephemeral" (private) or "in_channel" (public)
		Text         string `json:"text"`
	}

	justinResponse := &JustinResponse{
		Text: text,
	}
	if isPublic {
		justinResponse.ResponseType = "in_channel"
	} else {
		justinResponse.ResponseType = "ephemeral"
	}

	log.Debugf(ctx, "Marshalling JustinResponse: %#v", justinResponse)
	justinJSON, err := json.Marshal(justinResponse)
	if err != nil {
		log.Errorf(ctx, "Error marshalling JSON for JustinResponse: %#v - %s", justinResponse, err)
		return nil, err
	}

	log.Debugf(ctx, "Slack response: %s", string(justinJSON))
	return justinJSON, nil
}
开发者ID:wblakecaldwell,项目名称:justin,代码行数:28,代码来源:justin.go


示例7: fetchTokeninfo

// fetchTokeninfo retrieves token info from tokeninfoEndpointURL  (tokeninfo API)
func fetchTokeninfo(c context.Context, token string) (*tokeninfo, error) {
	url := tokeninfoEndpointURL + "?access_token=" + token
	log.Debugf(c, "Fetching token info from %q", url)
	resp, err := newHTTPClient(c).Get(url)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	log.Debugf(c, "Tokeninfo replied with %s", resp.Status)

	ti := &tokeninfo{}
	if err = json.NewDecoder(resp.Body).Decode(ti); err != nil {
		return nil, err
	}
	if resp.StatusCode != http.StatusOK {
		errMsg := fmt.Sprintf("Error fetching tokeninfo (status %d)", resp.StatusCode)
		if ti.ErrorDescription != "" {
			errMsg += ": " + ti.ErrorDescription
		}
		return nil, errors.New(errMsg)
	}

	switch {
	case ti.ExpiresIn <= 0:
		return nil, errors.New("Token is expired")
	case !ti.VerifiedEmail:
		return nil, fmt.Errorf("Unverified email %q", ti.Email)
	case ti.Email == "":
		return nil, fmt.Errorf("Invalid email address")
	}

	return ti, err
}
开发者ID:davars,项目名称:go-endpoints,代码行数:34,代码来源:auth_dev.go


示例8: clearLock

// clearLock clears the current lease, it should be called at the end of every task
// execution if things fail, to try and prevent unecessary locks and to count the
// number of retries
func (l *Locker) clearLock(c context.Context, key *datastore.Key, entity Lockable) error {
	lock := entity.getLock()
	if lock.Retries == l.MaxRetries {
		if l.AlertOnFailure {
			if err := alertAdmins(c, key, entity, "Permanent task failure"); err != nil {
				log.Errorf(c, "failed to send alert email for permanent task failure: %v", err)
			}
		}
		return ErrTaskFailed
	}
	err := storage.RunInTransaction(c, func(tc context.Context) error {
		if err := storage.Get(tc, key, entity); err != nil {
			log.Debugf(c, "clearLock get %v", err)
			return err
		}
		lock := entity.getLock()
		lock.Timestamp = getTime()
		lock.RequestID = ""
		lock.Retries++
		if _, err := storage.Put(tc, key, entity); err != nil {
			log.Debugf(c, "clearLock put %v", err)
			return err
		}
		return nil
	}, nil)
	return err
}
开发者ID:CaptainCodeman,项目名称:datastore-locker,代码行数:30,代码来源:task.go


示例9: cacheSameValues

func (a *MemcacheDatastoreAccessor) cacheSameValues(c context.Context, cacheKeys []string, data interface{}, expiration time.Duration) error {
	N := len(cacheKeys)

	var buffer bytes.Buffer
	enc := gob.NewEncoder(&buffer)
	err := enc.Encode(&data)

	if err != nil {
		log.Debugf(c, "Failed encoding for cache keys [%v] : %v", cacheKeys, err)
		return err
	}

	items := make([]*memcache.Item, N)
	for i, cacheKey := range cacheKeys {
		cacheItem := &memcache.Item{
			Key:        cacheKey,
			Value:      buffer.Bytes(),
			Expiration: expiration,
		}
		items[i] = cacheItem
	}

	// Set the items, unconditionally, in 1 batch call
	err = memcache.SetMulti(c, items)
	if err != nil {
		log.Debugf(c, "Failed setting cache items: %v", cacheKeys, err)
	}
	return err
}
开发者ID:Deleplace,项目名称:programming-idioms,代码行数:29,代码来源:dataAccessorMemcached.go


示例10: cacheValues

func (a *MemcacheDatastoreAccessor) cacheValues(c context.Context, cacheKeys []string, data []interface{}, expiration time.Duration) error {
	if len(cacheKeys) != len(data) {
		panic(fmt.Errorf("Wrong params length", len(cacheKeys), len(data)))
	}
	N := len(cacheKeys)

	var buffer bytes.Buffer
	enc := gob.NewEncoder(&buffer)

	items := make([]*memcache.Item, N)
	for i, cacheKey := range cacheKeys {
		cacheData := data[i]
		err := enc.Encode(&cacheData)
		if err != nil {
			log.Debugf(c, "Failed encoding for cache[%v] : %v", cacheKey, err)
			return err
		}
		cacheItem := &memcache.Item{
			Key:        cacheKey,
			Value:      buffer.Bytes(),
			Expiration: expiration,
		}
		items[i] = cacheItem
	}

	// Set the items, unconditionally, in 1 batch call
	err := memcache.SetMulti(c, items)
	if err != nil {
		log.Debugf(c, "Failed setting cache items: %v", cacheKeys, err)
	}
	return err
}
开发者ID:Deleplace,项目名称:programming-idioms,代码行数:32,代码来源:dataAccessorMemcached.go


示例11: commitBoardState

func commitBoardState(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	log.Debugf(c, "Commit Board State received!", nil)

	if r.Method != "POST" {
		http.Error(w, "Invalid method.", 500)
		return
	}

	dec := json.NewDecoder(r.Body)
	defer r.Body.Close()

	state := &BoardState{}
	err := dec.Decode(&state)
	if err != nil {
		http.Error(w, fmt.Sprintf("Failed to parse board state. %s", err.Error()), 500)
		return
	}
	log.Debugf(c, "Input: %v", state)

	newState, err := SaveGame(c, state)
	if err != nil {
		http.Error(w, fmt.Sprintf("Failed to save board state. %s", err.Error()), 500)
		return
	}

	enc := json.NewEncoder(w)
	err = enc.Encode(newState)
	if err != nil {
		http.Error(w, fmt.Sprintf("Failed to parse board state response. %s", err.Error()), 500)
		return
	}
}
开发者ID:jward6,项目名称:gopandemus,代码行数:33,代码来源:gopandemus.go


示例12: sendUpdate

func sendUpdate(ctx context.Context, g *Game) {
	fb, err := firebase(ctx)
	if err != nil {
		log.Errorf(ctx, "getFirebase: %v", err)
	}
	chans := fb.Child("channels")

	gameKey := g.K.Encode()

	if g.UserO != "" {
		channelID := g.UserO + gameKey
		if err := chans.Child(channelID).Set(g); err != nil {
			log.Errorf(ctx, "Updating UserO (%s): %v", channelID, err)
		} else {
			log.Debugf(ctx, "Update O sent.")
		}
	}

	if g.UserX != "" {
		channelID := g.UserX + gameKey
		if err := chans.Child(channelID).Set(g); err != nil {
			log.Errorf(ctx, "Updating UserX (%s): %v", channelID, err)
		} else {
			log.Debugf(ctx, "Update X sent.")
		}
	}
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:27,代码来源:main.go


示例13: SendAlerts

func SendAlerts(ctx context.Context, stocksForAlert []PortfolioStock) {
	if len(stocksForAlert) == 0 {
		log.Debugf(ctx, "SendAlerts: Alert stocks are empty")
		return
	}
	//group by user emails to send a consolidated email
	groupedStockAlerts := make(map[string][]PortfolioStock)
	for _, alert := range stocksForAlert {
		userPortfolioStocks := groupedStockAlerts[alert.Email]
		userPortfolioStocks = append(userPortfolioStocks, alert)
		groupedStockAlerts[alert.Email] = userPortfolioStocks
	}
	log.Debugf(ctx, "Will send alerts for ", Jsonify(groupedStockAlerts))
	for email, alerts := range groupedStockAlerts {
		msg := &mail.Message{
			Sender:  "NewTechFellas Stock Alerts <[email protected]>",
			To:      []string{email},
			Subject: "Newtechfellas stock alerts for your stocks - " + DateString(),
			Body:    getStocksAlertMailBody(alerts),
		}
		if err := mail.Send(ctx, msg); err != nil {
			log.Debugf(ctx, "Couldn't send email: %v", err)
		}
	}

	for _, portfolioStock := range stocksForAlert {
		portfolioStock.AlertSentTime = time.Now()
		//Save stocksForAlert to update last alert sent time
		CreateOrUpdate(ctx, &portfolioStock, portfolioStock.kind(), portfolioStock.stringId(), 0)
	}
}
开发者ID:newtechfellas,项目名称:StockAlerts,代码行数:31,代码来源:scheduler.go


示例14: cachedCerts

// cachedCerts fetches public certificates info from DefaultCertURI and
// caches it for the duration specified in Age header of a response.
func cachedCerts(c context.Context) (*certsList, error) {
	namespacedContext, err := appengine.Namespace(c, certNamespace)
	if err != nil {
		return nil, err
	}

	var certs *certsList

	_, err = memcache.JSON.Get(namespacedContext, DefaultCertURI, &certs)
	if err == nil {
		return certs, nil
	}

	// Cache miss or server error.
	// If any error other than cache miss, it's proably not a good time
	// to use memcache.
	var cacheResults = err == memcache.ErrCacheMiss
	if !cacheResults {
		log.Debugf(c, "%s", err.Error())
	}

	log.Debugf(c, "Fetching provider certs from: %s", DefaultCertURI)
	resp, err := newHTTPClient(c).Get(DefaultCertURI)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return nil, errors.New("Could not reach Cert URI or bad response.")
	}

	certBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	err = json.Unmarshal(certBytes, &certs)
	if err != nil {
		return nil, err
	}

	if cacheResults {
		expiration := certExpirationTime(resp.Header)
		if expiration > 0 {
			item := &memcache.Item{
				Key:        DefaultCertURI,
				Value:      certBytes,
				Expiration: expiration,
			}
			err = memcache.Set(namespacedContext, item)
			if err != nil {
				log.Errorf(c, "Error adding Certs to memcache: %v", err)
			}
		}
	}
	return certs, nil
}
开发者ID:davars,项目名称:go-endpoints,代码行数:58,代码来源:auth.go


示例15: GetValidUser

func GetValidUser(email string, ctx context.Context, w http.ResponseWriter, r *http.Request) (user User, err error) {
	//Is user verified
	if err = GetEntity(ctx, email, 0, "User", &user); err != nil {
		log.Debugf(ctx, "User not found for email ", email)
		return
	}
	if !user.IsVerified {
		log.Debugf(ctx, "User ", email, " is not verified")
		ErrorResponse(w, errors.New("User is not verified. Check your email to confirm the registration"), http.StatusBadRequest)
		return
	}
	return
}
开发者ID:newtechfellas,项目名称:StockAlerts,代码行数:13,代码来源:userhandlerfuncs.go


示例16: ServeHTTP

// ServeHTTP handles the HTTP request, by forwarding it to the target VM.
// If the VM is not up, it will be launched.
func (vm *VM) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	log.Debugf(c, "Servicing a new request with VM Proxy %s/%s", vm.Instance.Name, vm.ip)
	if !vm.IsRunning(c) {
		log.Debugf(c, "VM not running, starting a new one ...")
		if err := vm.Start(c); err != nil {
			log.Errorf(c, "Error starting VM: %v", err)
			http.Error(w, fmt.Sprintf("Failed to start VM: %v", err), http.StatusInternalServerError)
			return
		}
	}
	log.Debugf(c, "Forwarding request ...")
	vm.forward(c, w, r)
}
开发者ID:ronoaldo,项目名称:aetools,代码行数:16,代码来源:vmproxy.go


示例17: GetStocksUsingYql

func GetStocksUsingYql(ctx context.Context, symbols []string) (stocks []Stock, err error) {
	client := urlfetch.Client(ctx)
	quotedSymbols := MapStr(func(s string) string {
		return `"` + s + `"`
	}, symbols)

	query := fmt.Sprintf(`SELECT Symbol,Name,Open,LastTradePriceOnly,ChangeinPercent,DaysLow,DaysHigh,Change FROM %s WHERE symbol IN (%s)`,
		"yahoo.finance.quotes", strings.Join(quotedSymbols, ","))
	log.Debugf(ctx, "Quotes query = ", query)

	v := url.Values{}
	v.Set("q", query)
	v.Set("format", "json")
	v.Set("env", DatatablesUrl)
	url := PublicApiUrl + "?" + v.Encode()
	resp, err := client.Get(url)
	if err != nil {
		log.Debugf(ctx, "Failed to fetch data from YQL for ", url, " error is ", err)
		return
	}
	defer resp.Body.Close()
	httpBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Debugf(ctx, "Error in Reading from response body while fetching quote from YQL", err)
		return
	}
	log.Debugf(ctx, "Response from YQL is ", string(httpBody[:]))
	if len(symbols) == 1 {
		var sresp YqlJsonSingleQuoteResponse
		if err = json.Unmarshal(httpBody, &sresp); err != nil {
			log.Debugf(ctx, "Error in unmarshalling for single response ", err)
			return
		}
		stocks = append(stocks, sresp.Query.Results.Quote.toStock())
	} else {
		var resp YqlJsonQuoteResponse
		if err = json.Unmarshal(httpBody, &resp); err != nil {
			return
		}
		for _, q := range resp.Query.Results.Quote {
			stocks = append(stocks, q.toStock())
		}
	}
	for _, s := range stocks {
		s.LastUpdated = time.Now()
		cachedStocks[s.Symbol] = s //update the cache
	}
	return
}
开发者ID:newtechfellas,项目名称:StockAlerts,代码行数:49,代码来源:yahoo.go


示例18: projections

func projections(c context.Context, u User, days int) (int64, int64, error) {
	var projected, earned int64

	g := syncutil.Group{}

	g.Go(func() error {
		q := datastore.NewQuery("Task").
			Filter("Disabled = ", false).
			Filter("Assignee = ", u.Email)

		for t := q.Run(c); ; {
			var x Task
			_, err := t.Next(&x)
			if err == datastore.Done {
				return nil
			} else if err != nil {
				return err
			}

			log.Debugf(c, "Item worth %v every %v", x.Value, x.Period)

			projected += int64(float64(x.Value) * (float64(days) / float64(x.Period)))
		}
	})

	g.Go(func() error {
		q := datastore.NewQuery("LoggedTask").
			Filter("User = ", u.Key).
			Filter("Completed >=", time.Now().Add(-24*time.Hour*time.Duration(days)))

		for t := q.Run(c); ; {
			var x LoggedTask
			_, err := t.Next(&x)
			if err == datastore.Done {
				return nil
			} else if err != nil {
				return err
			}

			log.Debugf(c, "Logged task worth %v", x.Amount)

			earned += int64(x.Amount)
		}
	})
	g.Wait()

	return projected, earned, g.Err()
}
开发者ID:dustin,项目名称:sallingshome,代码行数:48,代码来源:main.go


示例19: twitterSearch

func twitterSearch(w http.ResponseWriter, r *http.Request) {
	ctx := appengine.NewContext(r)
	query := r.URL.Query().Get("q")
	hash := r.URL.Query().Get("h")
	log.Debugf(ctx, "Twitter search", string(query))
	anaconda.SetConsumerKey("cW0kdWCjgnE8vpJGOvUxe4epL")
	anaconda.SetConsumerSecret("GEcenuc4kLzZLAfYddfC3PovRVdAu3CL3n9sc61zikH4wK2eDw")
	api := anaconda.NewTwitterApi("", "")
	api.HttpClient.Transport = &urlfetch.Transport{Context: ctx}
	v := url.Values{
		"result_type":      {"mixed"},
		"count":            {"1000"},
		"include_entities": {"false"},
	}
	if hash == "true" {
		query = "#" + query
	} else {
		query = "@" + query
	}
	searchResult, _ := api.GetSearch(url.QueryEscape(string(query)), v)
	js, err := json.Marshal(searchResult.Statuses[rand.Intn(len(searchResult.Statuses))])
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.Header().Set("Content-Type", "application/json")
	w.Write(js)
}
开发者ID:areguig,项目名称:golang-learning,代码行数:28,代码来源:main.go


示例20: jobTrackTimezoneHandler

func jobTrackTimezoneHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
	c := appengine.NewContext(r)

	defaultTP := f.Track.ClosestTrackpoint(sfo.KFixes["EPICK"])
	adsbTP := f.Tracks["ADSB"].ClosestTrackpoint(sfo.KFixes["EPICK"])
	trackTimeDelta := defaultTP.TimestampUTC.Sub(adsbTP.TimestampUTC)

	str := fmt.Sprintf("OK, looked up %s\n Default: %s\n ADSB   : %s\n delta: %s\n",
		f, defaultTP, adsbTP, trackTimeDelta)

	if trackTimeDelta < -4*time.Hour || trackTimeDelta > 4*time.Hour {
		str += fmt.Sprintf("* recoding\n* before: %s\n", f.Tracks["ADSB"])

		for i, _ := range f.Tracks["ADSB"] {
			f.Tracks["ADSB"][i].TimestampUTC = f.Tracks["ADSB"][i].TimestampUTC.Add(time.Hour * -8)
		}
		str += fmt.Sprintf("* after : %s\n", f.Tracks["ADSB"])

		db := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
		if err := db.UpdateFlight(*f); err != nil {
			log.Errorf(c, "Persist Flight %s: %v", f, err)
			return str, err
		}
		log.Infof(c, "Updated flight %s", f)
		str += fmt.Sprintf("--\nFlight was updated\n")

	} else {
		log.Debugf(c, "Skipped flight %s, delta=%s", f, trackTimeDelta)
		str += "--\nFlight was OK, left untouched\n"
	}

	return str, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:33,代码来源:flight-batch.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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