Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Structured key-value logger without breaking order of fields. 🔧

License

NotificationsYou must be signed in to change notification settings

reconquest/cog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package provides to structured log both for displaying it sanely in the stderrlogs as well as sending key-valued logs into any log storage such as ElasticSearch.

To setup basic stderr logging, use following snippet in yourmain.go:

import"github.com/reconquest/cog"// ...stderr:=lorg.NewLog()stderr.SetIndentLines(true)stderr.SetFormat(lorg.NewFormat("${time} ${level:[%s]:right:short} ${prefix}%s"),)ifargs["--debug"].(bool) {stderr.SetLevel(lorg.LevelDebug)}log=cog.NewLogger(stderr)// use like thatlog.Infof(nil,"message to log: %d",1)log.Infof(karma.Describe("key","value"),"message to log: %d",1)err:=errors.New("some error")log.Fatalf(karma.Describe("context","testing error").Reason(err),"message to log: %d",1,)

To see more examples of how to usekarma for structured logging and errorreporting, considerlooking at tests and examples.

Motivation

Following package offers significant improvements abovelogrus and similarstructured loggers:

  • Readable tree-like log entries in stderr, which makes easy to debug program,because log is more readable.
  • Allows to use context errors, that used to describe errors on all call-stacklevels to ease finding problems and fixing them.
  • Sends logs to ES in key-value format like other structured loggers.
  • Does not change ordering of key-values in the context.

License

This project is licensed under the terms of the MIT license.

About

Structured key-value logger without breaking order of fields. 🔧

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp