Skip to content

Navigation Menu

Sign in
Appearance settings

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
Appearance settings

Implement slog.LogValuer #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nozo-moto wants to merge 3 commits into cockroachdb:master
base: master
Choose a base branch
Loading
from nozo-moto:implment-logvalue-method-to-withstack

Conversation

@nozo-moto
Copy link

@nozo-moto nozo-moto commented Sep 18, 2023
edited
Loading

#107

This change is Reviewable

code
package main
import (
	"context"
	"log/slog"
	"os"
	"github.com/cockroachdb/errors"
)
func f1() error {
	return errors.Wrap(f2(), "wrapped error 1")
}
func f2() error {
	return errors.Wrap(f3(), "wrapped error 2")
}
func f3() error {
	return errors.Wrap(f4(), "wrapped error 3")
}
func f4() error {
	return errors.Wrap(f5(), "wrapped error 4")
}
func f5() error {
	return errors.New("error root")
}
func main() {
	ctx := context.Background()
	err := f1()
	logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
	logger.InfoContext(ctx, "test", slog.Any("error", err))
}
result
{
 "time": "2023年09月18日T17:57:09.438517+09:00",
 "level": "INFO",
 "msg": "test",
 "error": {
 "message": "wrapped error 1: wrapped error 2: wrapped error 3: wrapped error 4: error root",
 "stacktrace": {
 "main.f1": {
 "file": "/Users/nozo/tmp/cockloaddb-slog-try/main.go",
 "name": "main.f1",
 "line": 12
 },
 "main.main": {
 "file": "/Users/nozo/tmp/cockloaddb-slog-try/main.go",
 "name": "main.main",
 "line": 33
 },
 "runtime.main": {
 "file": "/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go",
 "name": "runtime.main",
 "line": 267
 },
 "runtime.goexit": {
 "file": "/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s",
 "name": "runtime.goexit",
 "line": 1197
 }
 }
 }
}

lexfrei reacted with thumbs up emoji
Copy link
Member

cockroach-teamcity commented Sep 18, 2023
edited
Loading

CLA assistant check
All committers have signed the CLA.

@nozo-moto nozo-moto changed the title (削除) implement LogValue method to WithStack (削除ここまで) (追記) Implement slog.LogValuer (追記ここまで) Sep 18, 2023
@nozo-moto nozo-moto force-pushed the implment-logvalue-method-to-withstack branch from adf5647 to 556c210 Compare September 18, 2023 09:00
@nozo-moto nozo-moto marked this pull request as ready for review September 18, 2023 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /