All Projects → tommy351 → zap-stackdriver

tommy351 / zap-stackdriver

Licence: MIT License
Prints Stackdriver format logs with zap.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to zap-stackdriver

Go-Gin-Api
基于golang开源框架 gin封装的api框架
Stars: ✭ 42 (+35.48%)
Mutual labels:  zap
network-pipeline
Network traffic data pipeline for real-time predictions and building datasets for deep neural networks
Stars: ✭ 36 (+16.13%)
Mutual labels:  zap
kube-owasp-zap
Owasp Zap chart for Kubernetes
Stars: ✭ 38 (+22.58%)
Mutual labels:  zap
hakbot-origin-controller
Vendor-Neutral Security Tool Automation Controller (over REST)
Stars: ✭ 30 (-3.23%)
Mutual labels:  zap
public
util toolkit for go.golang 通用函数包
Stars: ✭ 135 (+335.48%)
Mutual labels:  zap
go2sky-plugins
The plugins of go2sky
Stars: ✭ 46 (+48.39%)
Mutual labels:  zap
logbench
Structured JSON logging Go libraries benchmark
Stars: ✭ 19 (-38.71%)
Mutual labels:  zap
zap-examples
Examples of using Uber's zap Go logging library
Stars: ✭ 92 (+196.77%)
Mutual labels:  zap
zap
⚡ Delightful AppImage package manager
Stars: ✭ 354 (+1041.94%)
Mutual labels:  zap
pink-lady
a template project of gin app.
Stars: ✭ 44 (+41.94%)
Mutual labels:  zap
www-project-zap
OWASP Zed Attack Proxy project landing page.
Stars: ✭ 52 (+67.74%)
Mutual labels:  zap
logging
mod: zap logging in golang
Stars: ✭ 44 (+41.94%)
Mutual labels:  zap
Go-Clean-Architecture-REST-API
Golang Clean Architecture REST API example
Stars: ✭ 376 (+1112.9%)
Mutual labels:  zap
zap-sonar-plugin
Integrates OWASP Zed Attack Proxy reports into SonarQube
Stars: ✭ 66 (+112.9%)
Mutual labels:  zap
owasp-zap-fileupload-addon
OWASP ZAP add-on for finding vulnerabilities in File Upload functionality.
Stars: ✭ 19 (-38.71%)
Mutual labels:  zap
k3log
三大王日志,一款开箱即用且高效,快捷,安全的golang日志,基于uber zap
Stars: ✭ 32 (+3.23%)
Mutual labels:  zap
golang-example-app
Example application
Stars: ✭ 138 (+345.16%)
Mutual labels:  zap
Zap
Blazing fast, structured, leveled logging in Go.
Stars: ✭ 14,384 (+46300%)
Mutual labels:  zap
Zaproxy
The OWASP ZAP core project
Stars: ✭ 9,078 (+29183.87%)
Mutual labels:  zap

zap-stackdriver

GitHub tag (latest SemVer) go.dev reference Test codecov

Prints Stackdriver format logs with zap.

Installation

go get github.com/tommy351/zap-stackdriver

Usage

package main

import (
	"github.com/tommy351/zap-stackdriver"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)

func main() {
	config := &zap.Config{
		Level:            zap.NewAtomicLevelAt(zapcore.InfoLevel),
		Encoding:         "json",
		EncoderConfig:    stackdriver.EncoderConfig,
		OutputPaths:      []string{"stdout"},
		ErrorOutputPaths: []string{"stderr"},
	}

	logger, err := config.Build(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
		return &stackdriver.Core{
			Core: core,
		}
	}), zap.Fields(
		stackdriver.LogServiceContext(&stackdriver.ServiceContext{
			Service: "foo",
			Version: "bar",
		}),
	))

	if err != nil {
		panic(err)
	}

	logger.Info("Hello",
		stackdriver.LogUser("token"),
		stackdriver.LogHTTPRequest(&stackdriver.HTTPRequest{
			Method:             "GET",
			URL:                "/foo",
			UserAgent:          "bar",
			Referrer:           "baz",
			ResponseStatusCode: 200,
			RemoteIP:           "1.2.3.4",
		}))
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].