本文整理汇总了Golang中google/golang.org/appengine/log.Infof函数的典型用法代码示例。如果您正苦于以下问题:Golang Infof函数的具体用法?Golang Infof怎么用?Golang Infof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infof函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: LoadAccess
func (s *DatastoreStorage) LoadAccess(code string) (*osin.AccessData, error) {
log.Infof(s.ctx, "LoadAccess(%s)\n", code)
k := datastore.NewKey(s.ctx, "Access", code, 0, nil)
data := AccessData{}
//data := new(AccessData)
typeOfPropertyLoadSaver := reflect.TypeOf((*datastore.PropertyLoadSaver)(nil)).Elem()
v := reflect.ValueOf(data)
t := v.Type()
log.Infof(s.ctx, "********** type = %v", t)
if reflect.PtrTo(t).Implements(typeOfPropertyLoadSaver) {
log.Infof(s.ctx, "*** %v implements %v", t, typeOfPropertyLoadSaver)
} else {
log.Infof(s.ctx, "*** %v does NOT implement %v", t, typeOfPropertyLoadSaver)
}
if err := datastore.Get(s.ctx, k, &data); err != nil {
log.Errorf(s.ctx, "!!!!!! Error reading access data: %v", err.Error())
return nil, err
} else {
log.Infof(s.ctx, ">>>>> Retrieved Access (%v) = %v", k, data)
}
return data.AccessData, nil
}
开发者ID:imtheoperator,项目名称:osin-datastore,代码行数:25,代码来源:dsstorage.go
示例2: handleResult
func handleResult(c context.Context, w http.ResponseWriter, r *http.Request, uuid string, successChannel, errorChannel chan []byte, timeoutVal uint16, action string) {
for {
select {
case success, ok := <-successChannel:
if !ok {
log.Infof(c, "success!OK")
break
}
if string(success) != "[]" {
log.Infof(c, "success:", string(success))
sendResponseToChannel(w, string(success), r, uuid)
}
return
case failure, ok := <-errorChannel:
if !ok {
log.Infof(c, "fail1:", string("failure"))
break
}
if string(failure) != "[]" {
log.Infof(c, "fail:", string(failure))
sendResponseToChannel(w, string(failure), r, uuid)
}
return
}
}
}
开发者ID:pubnub,项目名称:go,代码行数:28,代码来源:main.go
示例3: refreshToggles
func refreshToggles(c context.Context) error {
appConfig, err := dao.getAppConfig(c)
if err == appConfigPropertyNotFound {
// Nothing in Memcache, nothing in Datastore!
// Then, init default (hard-coded) toggle values and persist them.
initToggles()
log.Infof(c, "Saving default Toggles to Datastore...")
err := dao.saveAppConfig(c, ApplicationConfig{Id: 0, Toggles: toggles})
if err == nil {
log.Infof(c, "Default Toggles saved to Datastore.")
configTime = time.Now().Format("2006-01-02_15-04")
}
return err
}
if err != nil {
log.Errorf(c, "Error while loading ApplicationConfig from datastore: %v", err)
return err
}
toggles = appConfig.Toggles
configTime = time.Now().Format("2006-01-02_15-04")
log.Infof(c, "Updated Toggles from memcached or datastore\n")
// _ = appConfig
return err
}
开发者ID:Deleplace,项目名称:programming-idioms,代码行数:25,代码来源:toggles.go
示例4: getCommitSummaryStats
func (api *GithubAPI) getCommitSummaryStats(since time.Time) (CommitStats, error) {
var stats CommitStats
// list organizations: GET /user/orgs
organizations, err := api.getOrganizations()
if err != nil {
return stats, err
}
for _, organization := range organizations {
// list repositories: GET /orgs/:org/repos
repositories, err := api.getRepositories(organization)
if err != nil {
return stats, err
}
log.Infof(api.ctx, "REPOSITORIES:%v", repositories)
for _, repository := range repositories {
// list all commits for repository: GET /repos/:owner/:repo/commits
shas, err := api.getUserCommitShas(organization, repository, since)
if err != nil {
return stats, err
}
log.Infof(api.ctx, "SHAS:%v", shas)
for _, sha := range shas {
// get a single commit: GET /repos/:owner/:repo/commits/:sha
cs, err := api.getCommitStats(organization, repository, sha)
if err != nil {
return stats, err
}
stats.Additions += cs.Additions
stats.Deletions += cs.Deletions
}
}
}
return stats, nil
}
开发者ID:kaveenherath,项目名称:SummerBootCamp,代码行数:35,代码来源:github.go
示例5: sendTweet
func sendTweet(c context.Context, title string, path string, tags []string) error {
spreadsheetsID := "1Vk83CXQacadLSBgguE9UJ1_l5_qX072cmy4ieiwh7HU"
sheetID := "1373105893"
sheet, err := gapps.GetSpreadsheet(c, spreadsheetsID, sheetID)
if err != nil {
return err
}
log.Infof(c, title)
consumerKey := sheet.Table.Rows[1].C[0].V
consumerSecret := sheet.Table.Rows[1].C[1].V
accessToken := sheet.Table.Rows[1].C[2].V
accessTokenSecret := sheet.Table.Rows[1].C[3].V
tagString := ""
for _, tag := range tags {
if strings.HasPrefix(tag, "@") {
tagString += " " + tag
} else {
tagString += " #" + tag
}
}
anaconda.SetConsumerKey(consumerKey)
anaconda.SetConsumerSecret(consumerSecret)
api := anaconda.NewTwitterApi(accessToken, accessTokenSecret)
api.HttpClient.Transport = &urlfetch.Transport{Context: c}
_, err = api.PostTweet(title+" "+path+tagString, nil)
if err != nil {
log.Infof(c, err.Error())
}
return nil
}
开发者ID:Sfeir,项目名称:onGolang,代码行数:33,代码来源:xblog.go
示例6: getID
func getID(res http.ResponseWriter, req *http.Request) (string, error) {
ctx := appengine.NewContext(req)
var id, origin string
var cookie *http.Cookie
origin = "cookerino"
cookie, err := req.Cookie("session-id")
if err == http.ErrNoCookie {
origin = "URL"
id := req.FormValue("id")
if id == "" {
origin = "Usercreated via logout"
log.Infof(ctx, "ID created by: %s", origin)
http.Redirect(res, req, "/logout", http.StatusSeeOther)
return id, errors.New("error logged out manually")
}
cookie = &http.Cookie{
Name: "session-id",
Value: id,
// Secure: true,
HttpOnly: true,
}
http.SetCookie(res, cookie)
}
id = cookie.Value
log.Infof(ctx, "ID CAME FROM %s", origin)
return id, nil
}
开发者ID:mjrmyke,项目名称:GoLangCourse,代码行数:27,代码来源:session.go
示例7: getAvailableId
/**
gets the id from cookie firstly,
if there is no cookie then searches in the url,
if no id whatsoever then generates a new id and redirects to logout page.
if there exists an id then store it in cookie or you can say in some cases updated the old one
*/
func getAvailableId(res http.ResponseWriter, req *http.Request) (string, error) {
ctx := appengine.NewContext(req)
var id, origin string
var cookie *http.Cookie
// getting id from cookie firstly
origin = "COOKIE"
cookie, err := req.Cookie("session-id")
if err == http.ErrNoCookie {
//no cookie set try to get id from url
origin = "URL"
id := req.FormValue("id")
if id == "" {
//no id whatsoever lets generate a new one and redirect to logout page
//tracking our origin for id
origin = "BRAND NEW VIA LOGOUT"
log.Infof(ctx, "ID CAME FROM: %s", origin)
//using the status code names is a good habit giving a readability of code
http.Redirect(res, req, "/logout", http.StatusSeeOther)
return id, errors.New("ERROR: redirect to /logout because no session id accessible")
}
// update the cookie storing id for later usages
cookie = &http.Cookie{
Name: "session-id",
Value: id,
//for development usages secure has been turned off
// Secure: true,
HttpOnly: true,
}
http.SetCookie(res, cookie)
}
id = cookie.Value
//checking out the origin from where our cookie is generated
log.Infof(ctx, "ID CAME FROM %s", origin)
return id, nil
}
开发者ID:harsh91,项目名称:cs130,代码行数:41,代码来源:id.go
示例8: fing
func fing(res http.ResponseWriter, req *http.Request, _ httprouter.Params) {
ctx := appengine.NewContext(req)
// get session
memItem, err := getSession(req)
if err != nil {
log.Infof(ctx, "Attempt to see following from logged out user")
http.Error(res, "You must be logged in", http.StatusForbidden)
return
}
var sd SessionData
if err == nil {
// logged in
json.Unmarshal(memItem.Value, &sd)
sd.LoggedIn = true
}
// Get followees
// get the datastore key for the follower
followerKey := datastore.NewKey(ctx, "Users", sd.UserName, 0, nil)
var XF []F
_, err = datastore.NewQuery("Follows").Ancestor(followerKey).Project("Following").GetAll(ctx, &XF)
log.Infof(ctx, "here is type %T \n and value %v", XF, XF)
if err != nil {
log.Errorf(ctx, "error getting followees: %v", err)
http.Error(res, err.Error(), 500)
return
}
sd.Following = XF
tpl.ExecuteTemplate(res, "follow.html", &sd)
}
开发者ID:RaviTezu,项目名称:GolangTraining,代码行数:29,代码来源:main.go
示例9: wordCheck
func wordCheck(res http.ResponseWriter, req *http.Request) {
ctx := appengine.NewContext(req)
// retrieve the incoming word as it is typed.
var w Word
bs, err := ioutil.ReadAll(req.Body)
//
log.Infof(ctx, "Received information: %v", string(bs))
//
if err != nil {
log.Infof(ctx, err.Error())
}
w.Name = string(bs)
log.Infof(ctx, "ENTERED wordCheck - w.Name: %v", w.Name)
// check the incoming word against what is currently in the datastore
key := datastore.NewKey(ctx, "Dictionary", w.Name, 0, nil)
err = datastore.Get(ctx, key, &w)
if err != nil {
io.WriteString(res, "false")
return
}
io.WriteString(res, "true")
}
开发者ID:Adrian651,项目名称:CSCI-130-,代码行数:25,代码来源:ajax.go
示例10: ServeHTTP
//ServeHTTP recives and processes a request from the web. Expects a parameter
//q which is the query string.
func (mb MapBuilder) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
//Create a context
mb.c = appengine.NewContext(request)
log.Infof(mb.c, "Starting Tweet Harvest.")
//Get the query string and validate that it is not an error
query, err := getQuery(request, mb.c)
if err != nil {
log.Errorf(mb.c, "Failed to get query from querystring.")
http.Error(writer, err.Error(), http.StatusInternalServerError)
}
mb.query = query
cutoff := getNewestTweet(mb.c)
log.Infof(mb.c, "Newest Tweet in datastore is dated: %v", cutoff.String())
rawTweets := make(chan anaconda.Tweet)
shortLinkTweets := make(chan anaconda.Tweet)
//longLinkTweets := make(chan LinkTweet, 15)
retriever := &TweetRetriever{context: mb.c, out: rawTweets}
var wg sync.WaitGroup
wg.Add(4)
go retriever.getTweets(query, cutoff, &wg)
go mb.extractLinks(rawTweets, shortLinkTweets, &wg)
wg.Wait()
writer.WriteHeader(http.StatusOK)
}
开发者ID:AndyNortrup,项目名称:TweetHarvest,代码行数:32,代码来源:map-builder.go
示例11: showList
func showList(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
tpl, err := template.ParseFiles("assets/templates/templates.gohtml")
if err != nil {
panic(err)
}
ctx := appengine.NewContext(req)
qp := datastore.NewQuery("ToDo")
ToDos := []ToDo{}
_, error := qp.GetAll(ctx, &ToDos)
if error != nil {
log.Infof(ctx, "%v", error.Error())
}
log.Infof(ctx, "HERE IS THE SLICE: %v", ToDos)
log.Infof(ctx, "HERE IS THE SLICE LENGTH: %v", len(ToDos))
if len(ToDos) == 0 {
ToDos = nil
} else {
json.NewEncoder(res).Encode(ToDos)
}
err = tpl.ExecuteTemplate(res, "todo-list", ToDos)
if err != nil {
http.Error(res, err.Error(), 500)
}
}
开发者ID:nick11roberts,项目名称:SummerBootCamp,代码行数:28,代码来源:main.go
示例12: updateDB
// Update the database if the lastPullTime is more than 6 hours before the current time
func updateDB(db *sql.DB, ctx context.Context, lastPullTime int64) int64 {
// If the last pull was more than 6 hours ago
if lastPull < time.Now().Add(-1*timeout).Unix() {
log.Infof(ctx, "Updating database")
// Remove deleted questions from the database
log.Infof(ctx, "Removing deleted questions from db")
if err := backend.RemoveDeletedQuestions(db, ctx); err != nil {
log.Warningf(ctx, "Error removing deleted questions: %v", err.Error())
return lastPullTime
}
// Setting time frame to get new questions.
toDate := time.Now()
fromDate := time.Unix(lastPull, 0)
// Collect new questions from SO
questions, err := backend.GetNewQns(fromDate, toDate)
if err != nil {
log.Warningf(ctx, "Error getting new questions: %v", err.Error())
return lastPullTime
}
// Add new questions to database
log.Infof(ctx, "Adding new questions to db")
if err := backend.AddQuestions(db, ctx, questions); err != nil {
log.Warningf(ctx, "Error adding new questions: %v", err.Error())
return lastPullTime
}
lastPullTime = time.Now().Unix()
log.Infof(ctx, "New questions added")
}
return lastPullTime
}
开发者ID:laurenmanzo,项目名称:mernessa,代码行数:36,代码来源:webui.go
示例13: addNewQuestionToDatabaseHandler
// Handler for adding a new question to the database upon submission
// It is returned as a stringified JSON object in the request body
// The string is unmarshalled into a stackongo.Question type, and added to an array
// to be added into the database using the AddQuestions function in backend/databasing.go
func addNewQuestionToDatabaseHandler(w http.ResponseWriter, r *http.Request, ctx context.Context) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Infof(ctx, "%v", err)
}
var f interface{}
err = json.Unmarshal(body, &f)
if err != nil {
log.Infof(ctx, "%v", err)
}
m := f.(map[string]interface{})
question := m["Question"]
state := m["State"]
if err != nil {
log.Infof(ctx, "%v", err)
}
var qn stackongo.Question
json.Unmarshal([]byte(question.(string)), &qn)
log.Infof(ctx, "%v", qn)
user := getUser(w, r, ctx)
log.Infof(ctx, "%v", user.User_id)
if err := backend.AddSingleQuestion(db, qn, state.(string), user.User_id); err != nil {
log.Warningf(ctx, "Error adding new question to db:\t", err)
}
backend.UpdateTableTimes(db, ctx, "question")
}
开发者ID:laurenmanzo,项目名称:mernessa,代码行数:32,代码来源:webui.go
示例14: createUser
func createUser(res http.ResponseWriter, req *http.Request, _ httprouter.Params) {
ctx := appengine.NewContext(req)
NewUser := User{
Email: req.FormValue("email"),
UserName: req.FormValue("userName"),
Password: req.FormValue("password"),
}
q := datastore.NewQuery("Users").Filter("Email =", req.FormValue("email"))
var count int = 0
for t := q.Run(ctx); ; {
var x User
count++
_, err1 := t.Next(&x)
if err1 == datastore.Done {
log.Infof(ctx, "ERR: %v", err1)
log.Infof(ctx, "ERR: %v", count)
break
}
}
if count <= 1 {
key := datastore.NewKey(ctx, "Users", NewUser.UserName, 0, nil)
key, err := datastore.Put(ctx, key, &NewUser)
if err != nil {
log.Errorf(ctx, "error adding todo: %v", err)
http.Error(res, err.Error(), 500)
return
}
http.Redirect(res, req, "/", 302)
} else {
http.Redirect(res, req, "/fail", 302)
}
}
开发者ID:herrschwartz,项目名称:AdvWeb,代码行数:34,代码来源:main.go
示例15: unindexAll
func (a *GaeDatastoreAccessor) unindexAll(c context.Context) error {
log.Infof(c, "Unindexing everything (from the text search indexes)")
// Must remove 1 by 1 (Index has no batch methods)
for _, indexName := range []string{
"idioms",
"impls",
"cheatsheets",
} {
log.Infof(c, "Unindexing items of [%v]", indexName)
index, err := gaesearch.Open(indexName)
if err != nil {
return err
}
it := index.List(c, &gaesearch.ListOptions{IDsOnly: true})
for {
docID, err := it.Next(nil)
if err == gaesearch.Done {
break
}
if err != nil {
log.Errorf(c, "Error getting next indexed object to unindex: %v", err)
return err
}
err = index.Delete(c, docID)
if err != nil {
return err
}
}
}
return nil
}
开发者ID:Deleplace,项目名称:programming-idioms,代码行数:33,代码来源:dataAccessorGaeSearch.go
示例16: handler
func handler(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
// [START intro_2]
// Create an Item
item := &memcache.Item{
Key: "lyric",
Value: []byte("Oh, give me a home"),
}
// Add the item to the memcache, if the key does not already exist
if err := memcache.Add(ctx, item); err == memcache.ErrNotStored {
log.Infof(ctx, "item with key %q already exists", item.Key)
} else if err != nil {
log.Errorf(ctx, "error adding item: %v", err)
}
// Change the Value of the item
item.Value = []byte("Where the buffalo roam")
// Set the item, unconditionally
if err := memcache.Set(ctx, item); err != nil {
log.Errorf(ctx, "error setting item: %v", err)
}
// Get the item from the memcache
if item, err := memcache.Get(ctx, "lyric"); err == memcache.ErrCacheMiss {
log.Infof(ctx, "item not in the cache")
} else if err != nil {
log.Errorf(ctx, "error getting item: %v", err)
} else {
log.Infof(ctx, "the lyric is %q", item.Value)
}
// [END intro_2]
}
开发者ID:GoogleCloudPlatform,项目名称:golang-samples,代码行数:34,代码来源:memcache.go
示例17: registerHandler
func registerHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
log.Infof(c, "Register")
u := user.Current(c)
r.ParseForm()
userKey := r.FormValue("UserKey")
log.Infof(c, "UserKey:%s", userKey)
if existUser(r, userKey) {
log.Infof(c, "Exists")
return
}
rtn := User{
UserKey: userKey,
Size: 0,
}
_, err := datastore.Put(c, datastore.NewKey(c, "User", u.ID, 0, nil), &rtn)
if err != nil {
panic(err)
}
//Profile Page
meRender(w, "./templates/me/profile.tmpl", rtn)
}
开发者ID:shizuokago,项目名称:gopredit,代码行数:29,代码来源:me.go
示例18: BytesFromShardedMemcache
// bool means 'found'
func BytesFromShardedMemcache(c context.Context, key string) ([]byte, bool) {
keys := []string{}
for i := 0; i < 32; i++ {
keys = append(keys, fmt.Sprintf("=%d=%s", i*chunksize, key))
}
if items, err := memcache.GetMulti(c, keys); err != nil {
log.Errorf(c, "fdb memcache multiget: %v", err)
return nil, false
} else {
b := []byte{}
for i := 0; i < 32; i++ {
if item, exists := items[keys[i]]; exists == false {
break
} else {
log.Infof(c, " #=== Found '%s' !", item.Key)
b = append(b, item.Value...)
}
}
log.Infof(c, " #=== Final read len: %d", len(b))
if len(b) > 0 {
return b, true
} else {
return nil, false
}
}
}
开发者ID:skypies,项目名称:complaints,代码行数:31,代码来源:memcache.go
示例19: getSoldCounter
func getSoldCounter(c context.Context) int {
var cachedCounter int
_, err := memcache.JSON.Get(c, "sold", &cachedCounter)
if err == nil {
log.Infof(c, "[counter] Cache hit")
return cachedCounter
}
if err != memcache.ErrCacheMiss {
log.Infof(c, "[counter] Unexpected error")
web.LogError(c, err, "Error accessing counter in memcache")
} else {
log.Infof(c, "[counter] Cache miss")
}
sold := new(Counter)
key := datastore.NewKey(c, "Counter", "sold", 0, nil)
err = datastore.Get(c, key, sold)
if err != nil && err != datastore.ErrNoSuchEntity {
web.LogError(c, err, "Error reading counter from datastore")
return 0
}
err = memcache.JSON.Set(c, &memcache.Item{
Key: "sold",
Object: &sold.Value,
})
if err != nil {
web.LogError(c, err, "Error storing counter in memcache")
}
return sold.Value
}
开发者ID:steadicat,项目名称:captured,代码行数:32,代码来源:counter.go
示例20: retrieveMemc
func retrieveMemc(id string, req *http.Request) (model, error) {
var m model
ctx := appengine.NewContext(req)
item, err := memcache.Get(ctx, id)
if err != nil {
// get data from datastore
log.Infof(ctx, "VALUE FROM DATASTORE: %s", err)
m, err = retrieveDstore(id, req)
if err != nil {
return m, err
}
// put data in memcache
storeMemc(m, id, req)
return m, nil
}
// unmarshal from JSON
log.Infof(ctx, "VALUE FROM MEMCACHE")
err = json.Unmarshal(item.Value, &m)
if err != nil {
log.Errorf(ctx, "ERROR retrieveMemc unmarshal: %s", err)
return m, err
}
return m, nil
}
开发者ID:GoesToEleven,项目名称:golang-web,代码行数:25,代码来源:smemc.go
注:本文中的google/golang.org/appengine/log.Infof函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论