zapclilogger

package module
v0.0.0-...-1692e83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 3 Imported by: 0

README

zap-cli-logger

A Zap logger for easy use with CLI applications.

Why?

Sometimes an HTTP service has multiple binaries bundled with it. For example, there can be a package for the HTTP service itself, and some utility CLIs that use an API client for that HTTP service to do things.

In this case, it's nice to have CLI printing that leverages the same dependency as the HTTP server for logging to minimize the overall dependency footprint.

Usage

See the example for how to set it up:

➜  zap-cli-logger git:(develop) ✗ go build -o build/example ./example
➜  zap-cli-logger git:(develop) ✗ ./build/example
you should always see this, and if -verbose is set you should see it with context
you should always see this with context	{"some": "context"}
main.main
	/Users/hugo.torres/projects/taxfyle/zap-cli-logger/example/main.go:22
runtime.main
	/opt/homebrew/Cellar/go/1.23.1/libexec/src/runtime/proc.go:272
you should always see this with context	{"some": "context"}
main.main
	/Users/hugo.torres/projects/taxfyle/zap-cli-logger/example/main.go:23
runtime.main
	/opt/homebrew/Cellar/go/1.23.1/libexec/src/runtime/proc.go:272
➜  zap-cli-logger git:(develop) ✗ ./build/example -verbose
you should only see this if -verbose is set, and you should see it with context	{"some": "context"}
you should always see this, and if -verbose is set you should see it with context	{"some": "context"}
you should always see this with context	{"some": "context"}
main.main
	/Users/hugo.torres/projects/taxfyle/zap-cli-logger/example/main.go:22
runtime.main
	/opt/homebrew/Cellar/go/1.23.1/libexec/src/runtime/proc.go:272
you should always see this with context	{"some": "context"}
main.main
	/Users/hugo.torres/projects/taxfyle/zap-cli-logger/example/main.go:23
runtime.main
	/opt/homebrew/Cellar/go/1.23.1/libexec/src/runtime/proc.go:272

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(verbose bool) (*zap.Logger, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL