{"id":15860390,"url":"https://github.com/suzuki-shunsuke/logrus-error","last_synced_at":"2025-03-16T00:30:58.663Z","repository":{"id":43453339,"uuid":"401258320","full_name":"suzuki-shunsuke/logrus-error","owner":"suzuki-shunsuke","description":"Embed logrus.Fields into error","archived":false,"fork":false,"pushed_at":"2025-02-11T18:49:08.000Z","size":84,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-27T04:25:32.662Z","etag":null,"topics":["library","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suzuki-shunsuke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-30T07:43:51.000Z","updated_at":"2025-02-11T18:49:12.000Z","dependencies_parsed_at":"2024-07-30T04:50:45.649Z","dependency_job_id":"4215cd8f-f55c-4dcc-9416-742076c0538a","html_url":"https://github.com/suzuki-shunsuke/logrus-error","commit_stats":{"total_commits":57,"total_committers":4,"mean_commits":14.25,"dds":"0.38596491228070173","last_synced_commit":"9081e464476a503fa87ce151e2ad6782cbae7e84"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-shunsuke%2Flogrus-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-shunsuke%2Flogrus-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-shunsuke%2Flogrus-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-shunsuke%2Flogrus-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suzuki-shunsuke","download_url":"https://codeload.github.com/suzuki-shunsuke/logrus-error/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801635,"owners_count":20350107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","logging"],"created_at":"2024-10-05T22:00:24.200Z","updated_at":"2025-03-16T00:30:58.370Z","avatar_url":"https://github.com/suzuki-shunsuke.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logrus-error\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/suzuki-shunsuke/logrus-error.svg)](https://pkg.go.dev/github.com/suzuki-shunsuke/logrus-error)\n[![Build Status](https://github.com/suzuki-shunsuke/logrus-error/workflows/test/badge.svg)](https://github.com/suzuki-shunsuke/logrus-error/actions)\n[![GitHub last commit](https://img.shields.io/github/last-commit/suzuki-shunsuke/logrus-error.svg)](https://github.com/suzuki-shunsuke/logrus-error)\n[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/suzuki-shunsuke/logrus-error/main/LICENSE)\n\nGo small library to embed [logrus](https://github.com/sirupsen/logrus).Fields into error.\n\n## Motivation\n\nWith [fmt.Errorf](https://pkg.go.dev/fmt#Errorf), you can add additional context to error.\n\ne.g.\n\n```go\nfmt.Errorf(\"get a user: %w\", err)\n```\n\n[logrus](https://github.com/sirupsen/logrus) is one of most popular structured logging library.\n\ne.g.\n\n```go\nlogrus.WithFields(logrus.Fields{\n\t\"username\": username,\n}).WithError(err).Error(\"get a user\")\n```\n\n`fmt.Errorf` is very useful, but you can add only a string to error as context. You can't add structured data to error.\nIf you use logrus, you may want to add structured data to error.\n\n`logrus-error` is a small library to add structured data to error and get structured data from error for logging.\n\nMainly logrus-error provides only two simple API.\n\n* [WithFields](https://pkg.go.dev/github.com/suzuki-shunsuke/logrus-error/logerr#WithFields): Add structured data to error\n* [WithError](https://pkg.go.dev/github.com/suzuki-shunsuke/logrus-error/logerr#WithError): Get structured data from error and return logrus.Entry\n\nAS IS (without logrus-error)\n\n```go\nreturn fmt.Errorf(\"get a user (username: %s): %w\", username, err)\n```\n\n```go\nlogrus.WithError(err).Error(\"add a member to a group\")\n```\n\nTO BE (with logrus-error)\n\n```go\nreturn logerr.WithFields(fmt.Errorf(\"get a user: %w\", err), logrus.Fields{\n\t\"username\": username,\n})\n```\n\n```go\nentry := logrus.NewEntry(logrus.New())\nlogerr.WithError(entry, err).Error(\"add a member to a group\")\n```\n\nUsing logrus-error, you can add structured data to error as context. You don't have to construct a string with [fmt's format](https://pkg.go.dev/fmt#hdr-Printing).\n\n## Document\n\nPlease see https://pkg.go.dev/github.com/suzuki-shunsuke/logrus-error/logerr\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuzuki-shunsuke%2Flogrus-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuzuki-shunsuke%2Flogrus-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuzuki-shunsuke%2Flogrus-error/lists"}