samber / samber/oops

Zap example

Open
#1 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
990
Forks
45
Avg merge
5d 9h
Merged PRs (30d)
5

Description

Hi @samber,

I tried using oops with zap here is my example:

func main() {
	logger, _ := zap.NewProduction()
	err := oops.
		In("repository").
		Tags("database", "sql").
		With("deneme", "mehmet").
		Errorf("could not fetch user")

	logger.Error(err.Error(), zap.Error(err))
}
{"level":"error","ts":1684233642.017879,"caller":"test-api/main.go:17","msg":"could not fetch user","error":"could not fetch user","errorVerbose":"Oops: could not fetch user\nAt: 2023-05-16 10:40:42.017789 +0000 UTC\nDomain: repository\nTags: database, sql\nContext:\n  * deneme: mehmet\nStackstrace:\nOops: could not fetch user\n  --- at test-api/main.go:15 main()\n","stacktrace":"main.main/test-api/main.go:17"}

I couldn't achieve the log structure like your example in readme, would be great if I get errorVerbose as a json.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Go and zap example, then compare its output with the README example. Locate the code that formats oops errors for structured logging and determine the expected JSON representation for errorVerbose; done means the requested structure is produced and covered by the project's relevant tests, though no specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.