本文整理汇总了Golang中gopkg/in/inconshreveable/log15/v2.Logger.Info方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Info方法的具体用法?Golang Logger.Info怎么用?Golang Logger.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/inconshreveable/log15/v2.Logger
的用法示例。
在下文中一共展示了Logger.Info方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Logger
func Logger(inner http.Handler, name string, logger log.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
inner.ServeHTTP(w, r)
//fmt.Printf("%s\t%s\t%s\t%s", r.Method, r.RequestURI, name, time.Since(start))
logger.Info("Request", "method", r.Method, "uri", r.RequestURI, "name", name, "duration", time.Since(start))
})
}
示例2: exec
func (lua *LuaExt) exec(reqLogger log.Logger, app *LuaApp, appID, reqId, script string, w http.ResponseWriter, r *http.Request) int {
// FIXME(tsileo) a debug mode, with a defer/recover
// also parse the Lu error and show the bugging line!
start := time.Now()
httpClient := &http.Client{}
// Initialize internal Lua module written in Go
logger := loggerModule.New(reqLogger.New("ctx", "Lua"), start, reqId)
response := responseModule.New()
request := requestModule.New(r, reqId, lua.authFunc)
blobstore := blobstoreModule.New(lua.blobStore)
kvstore := kvstoreModule.New(lua.kvStore)
bewit := bewitModule.New(reqLogger.New("ctx", "Lua bewit module"), r)
template := templateModule.New()
// Initialize Lua state
L := luamod.NewState()
defer L.Close()
setCustomGlobals(L)
L.PreloadModule("request", request.Loader)
L.PreloadModule("response", response.Loader)
L.PreloadModule("logger", logger.Loader)
L.PreloadModule("blobstore", blobstore.Loader)
L.PreloadModule("kvstore", kvstore.Loader)
L.PreloadModule("bewit", bewit.Loader)
L.PreloadModule("template", template.Loader)
// TODO(tsileo) docstore module
// TODO(tsileo) cookies module
// TODO(tsileo) lru module
// TODO(tsileo) cache module => to cache response
// TODO(tsileo) load module from github directly?
// TODO(tsileo) ETag support
// 3rd party module
luajson.Preload(L)
L.PreloadModule("http", gluahttp.NewHttpModule(httpClient).Loader)
// Set some global variables
L.SetGlobal("reqID", luamod.LString(reqId))
L.SetGlobal("appID", luamod.LString(appID))
// Execute the code
if err := L.DoString(script); err != nil {
// FIXME better error, with debug mode?
panic(err)
}
// Apply the Response object to the actual response
response.WriteTo(w)
// TODO save the logRecords in the AppStats and find a way to serve them over Server-Sent Events
// keep them in memory with the ability to dump them in bulk as blob for later query
// logRecords := logger.Records()
for _, logRecord := range logger.Records() {
app.logs = append(app.logs, logRecord)
}
reqLogger.Info("Script executed", "response", response, "duration", time.Since(start))
return response.Status()
}
示例3: loggerFn
func loggerFn(handler http.Handler, logger log.Logger, clientIP string, rw *hh.ResponseWriter, req *http.Request) {
start := time.Now()
handler.ServeHTTP(rw, req)
switch rw.Status() {
case 200, 307, 0: // 0 == 200 OK
default:
logger.Info("request completed", "method", req.Method, "path", req.URL.Path, "client_ip", clientIP, "status", rw.Status(), "duration", time.Since(start))
}
}
示例4: updateIssueReviewLabels
func updateIssueReviewLabels(client *github.Client, log log15.Logger, review ReviewRequest) error {
oldLabels := []string{}
newLabels := []string{review.CalculateAppropriateStatus()}
foundReviewLabel, incorrectReviewLabel := false, false
for _, l := range review.issue.Labels {
oldLabels = append(oldLabels, *l.Name)
switch *l.Name {
case WIPLabel, CakedLabel, AwaitingCakeLabel:
foundReviewLabel = true
if *l.Name != newLabels[0] {
incorrectReviewLabel = true
}
continue
default:
newLabels = append(newLabels, *l.Name)
}
}
var labelsNeedUpdating bool
switch {
case !foundReviewLabel:
labelsNeedUpdating = true
log.Info("could not find review label", "old_labels", oldLabels, "new_labels", newLabels)
case incorrectReviewLabel:
labelsNeedUpdating = true
log.Info("review label is incorrect", "old_labels", oldLabels, "new_labels", newLabels)
default:
log.Info("review label does not need updating", "labels", oldLabels)
}
if labelsNeedUpdating {
_, _, err := client.Issues.ReplaceLabelsForIssue(*review.repo.Owner.Login, *review.repo.Name, review.Number(), newLabels)
if err != nil {
log.Error("unable to update issue review label", "err", err)
return err
}
}
return nil
}
示例5: defaultLoggerFn
func defaultLoggerFn(handler http.Handler, logger log.Logger, clientIP string, rw *ResponseWriter, req *http.Request) {
start := time.Now()
logger.Info("request started", "method", req.Method, "path", req.URL.Path, "client_ip", clientIP)
handler.ServeHTTP(rw, req)
logger.Info("request completed", "status", rw.Status(), "duration", time.Since(start))
}