Grohl

Go 的组合日志记录、异常报告和指标库。「Combination logging, exception reporting, and metrics library for Go.」

  • 所有者: technoweenie/grohl
  • 平台: Linux, Mac, Windows
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Grohl(格罗尔)

Grohl 是一个有思想的库,用于收集有关应用程序在生产环境中的运行方式的指标和数据。 它通过在 key=value 结构中写入日志来实现。 它还提供用于将异常或指标发送到外部服务的接口。

这是 asenchi/scrolls 的 Go 版本。 该库的名称来自将单词“go”和“scrolls”混在一起。 此外,Dave Grohl(Foo Fighters 的主唱)也热衷于事件驱动指标。

有关该库背后的原理,请参见此博客文章

安装

$ go get github.com/technoweenie/grohl

然后导入它

import "github.com/technoweenie/grohl"

用法

Grohl 几乎不需要任何准备。默认情况下,所有内容都写入到 STDOUT。下面是一个快速的 http 服务器示例。

package main
import (
  "github.com/technoweenie/grohl"
  "log"
  "net/http"
)
func main() {
  grohl.AddContext("app", "example")
  http.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) {
    grohl.Log(grohl.Data{"path": r.URL.Path})
    fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
  })
  log.Fatal(http.ListenAndServe(":8080", nil))
}

这会在每个HTTP请求上写一条日志,例如:

now=2013-10-14T15:04:05-0700 app=example path=/foo

有关指标、statsd 集成和自定义错误报告器的详细信息,请参见 godocs

关于补丁/请求请求的注释

  1. 在 GitHub 上分叉该项目。
  2. 进行功能补充或错误修复。
  3. 为此添加测试。 这很重要,因此我不会在以后的版本中无意间破坏它。
  4. 提交,不要弄乱 rakefile、版本或历史记录。 (如果你想有自己的版本,这很好但是在提交的时候我可以忽略 bump版本)
  5. 给我发送拉请求。主题分支的额外加分。


(The first version translated by vz on 2020.08.01)

主要指标

概览
名称与所有者technoweenie/grohl
主编程语言Go
编程语言Go (语言数: 2)
平台Linux, Mac, Windows
许可证MIT License
所有者活动
创建于2013-08-28 22:37:12
推送于2016-06-07 15:24:19
最后一次提交2014-09-24 14:42:39
发布数0
用户参与
星数165
关注者数7
派生数10
提交数145
已启用问题?
问题数3
打开的问题数0
拉请求数14
打开的拉请求数0
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

Grohl

Grohl is an opinionated library for gathering metrics and data about how your
applications are running in production. It does this through writing logs
in a key=value structure. It also provides interfaces for sending exceptions
or metrics to external services.

This is a Go version of asenchi/scrolls.
The name for this library came from mashing the words "go" and "scrolls"
together. Also, Dave Grohl (lead singer of Foo Fighters) is passionate about
event driven metrics.

See this blog post for the rationale behind this library.

Installation

$ go get github.com/technoweenie/grohl

Then import it:

import "github.com/technoweenie/grohl"

Usage

Grohl takes almost no setup. Everything writes to STDOUT by default. Here's a
quick http server example:

package main

import (
  "github.com/technoweenie/grohl"
  "log"
  "net/http"
)

func main() {
  grohl.AddContext("app", "example")

  http.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) {
    grohl.Log(grohl.Data{"path": r.URL.Path})
    fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
  })

  log.Fatal(http.ListenAndServe(":8080", nil))
}

This writes a log on every HTTP request like:

now=2013-10-14T15:04:05-0700 app=example path=/foo

See the godocs for details on
metrics, statsd integration, and custom error reporters.

Note on Patches/Pull Requests

  1. Fork the project on GitHub.
  2. Make your feature addition or bug fix.
  3. Add tests for it. This is important so I don't break it in a future version
    unintentionally.
  4. Commit, do not mess with rakefile, version, or history. (if you want to have
    your own version, that is fine but bump version in a commit by itself I can
    ignore when I pull)
  5. Send me a pull request. Bonus points for topic branches.