{"id":13621115,"url":"https://github.com/gogap/logrus_mate","last_synced_at":"2026-02-19T04:33:24.650Z","repository":{"id":53086180,"uuid":"44371092","full_name":"gogap/logrus_mate","owner":"gogap","description":"tool for logrus, let it easy to use","archived":false,"fork":false,"pushed_at":"2021-04-07T09:44:15.000Z","size":90,"stargazers_count":161,"open_issues_count":4,"forks_count":40,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-14T22:38:22.303Z","etag":null,"topics":["graylog","logger","logrus","logstash"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gogap.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}},"created_at":"2015-10-16T08:03:07.000Z","updated_at":"2025-03-24T15:05:36.000Z","dependencies_parsed_at":"2022-09-02T06:04:21.383Z","dependency_job_id":null,"html_url":"https://github.com/gogap/logrus_mate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/gogap/logrus_mate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Flogrus_mate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Flogrus_mate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Flogrus_mate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Flogrus_mate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gogap","download_url":"https://codeload.github.com/gogap/logrus_mate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Flogrus_mate/sbom","scorecard":{"id":433844,"data":{"date":"2025-08-11","repo":{"name":"github.com/gogap/logrus_mate","commit":"9a2a70971c0783d433a9078896df5358eb18b7bf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":3,"reason":"Found 7/21 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T04:06:31.232Z","repository_id":53086180,"created_at":"2025-08-19T04:06:31.233Z","updated_at":"2025-08-19T04:06:31.233Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29603103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T04:01:40.476Z","status":"ssl_error","status_checked_at":"2026-02-19T04:01:12.960Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["graylog","logger","logrus","logstash"],"created_at":"2024-08-01T21:01:02.637Z","updated_at":"2026-02-19T04:33:24.620Z","avatar_url":"https://github.com/gogap.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Logrus Mate \u003cimg src=\"http://i.imgur.com/hTeVwmJ.png\" width=\"40\" height=\"40\" alt=\":walrus:\" class=\"emoji\" title=\":walrus:\"/\u003e\n\n**Logrus mate** is a tool for [Logrus](https://github.com/sirupsen/logrus), it will help you to initial logger by config, including `Formatter`, `Hook`，`Level` and `Output` .\n\n\u003e If you more prefer old version, you could checkout tag v1.0.0\n\n#### Example\n\n**Example 1:**\n\nHijack `logrus.StandardLogger()`\n\n```go\npackage main\n\nimport (\n    \"github.com/sirupsen/logrus\"\n    \"github.com/gogap/logrus_mate\"\n)\n\nfunc main() {\n    logrus_mate.Hijack(\n        logrus.StandardLogger(),\n        logrus_mate.ConfigString(\n            `{formatter.name = \"json\"}`,\n        ),\n    )\n    \n    logrus.WithField(\"Field\", \"A\").Debugln(\"Hello JSON\")\n}\n\n```\n\n**Example 2:**\n\nCreate new logger from mate:\n\n```go\npackage main\n\nimport (\n    \"github.com/gogap/logrus_mate\"\n)\n\nfunc main() {\n    mate, _ := logrus_mate.NewLogrusMate(\n        logrus_mate.ConfigString(\n            `{ mike {formatter.name = \"json\"} }`,\n        ),\n    )\n    \n    mikeLoger := mate.Logger(\"mike\")\n    mikeLoger.Errorln(\"Hello Error Level from Mike and my formatter is json\")\n}\n```\n\n**Example 3:**\n\nHi jack logger by mate\n\n```go\npackage main\n\nimport (\n    \"github.com/sirupsen/logrus\"\n    \"github.com/gogap/logrus_mate\"\n)\n\nfunc main() {\n    mate, _ := logrus_mate.NewLogrusMate(\n        logrus_mate.ConfigString(\n            `{ mike {formatter.name = \"json\"} }`,\n        ),\n    )\n\n    mate.Hijack(\n        logrus.StandardLogger(),\n        \"mike\",\n    )\n    \n    logrus.Println(\"hello std logger is hijack by mike\")\n}\n```\n\n**Example 4:**\n\nFallback the ConfigString\n\n```go\npackage main\n\nimport (\n    \"github.com/sirupsen/logrus\"\n    \"github.com/gogap/logrus_mate\"\n)\n\nfunc main() {\n    mate, _ := logrus_mate.NewLogrusMate(\n        logrus_mate.ConfigString(\n            `{ mike {formatter.name = \"json\"} }`,\n        ),\n        logrus_mate.ConfigFile(\n            \"mate.conf\", // { mike {formatter.name = \"text\"} }\n        ),\n    )\n\n    mate.Hijack(\n        logrus.StandardLogger(),\n        \"mike\",\n    )\n    \n    logrus.Println(\"hello std logger is hijack by mike\")\n}\n```\n\n **the `json` formatter is used**\n\n**Example 5:**\n\nFallback config while hijack\n\n```go\npackage main\n\nimport (\n    \"github.com/sirupsen/logrus\"\n    \"github.com/gogap/logrus_mate\"\n)\n\nfunc main() {\n    mate, _ := logrus_mate.NewLogrusMate(\n        logrus_mate.ConfigFile(\n            \"mate.conf\", // { mike {formatter.name = \"text\"} }\n        ),\n    )\n\n    mate.Hijack(logrus.StandardLogger(),\n        \"mike\",\n        logrus_mate.ConfigString(\n            `{formatter.name = \"json\"}`,\n        ),\n    )\n\n    logrus.Errorln(\"hello std logger is hijack by mike\")\n}\n```\n\n**the `json` formatter is used**\n\n\u003e currently we are using https://github.com/go-akka/configuration for logger config, it will more powerful config format for human read, \nyou also could set your own config provider\n\n#### Hooks\n| Hook  | Options |\n| ----- | ----------- |\n| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | `project-id` `api-key` `env`|\n| [Syslog](https://github.com/sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | `network` `address` `priority` `tag`|\n| [BugSnag](https://github.com/sirupsen/logrus/blob/master/hooks/bugsnag/bugsnag.go) | `api-key` |\n| [Slackrus](https://github.com/johntdyer/slackrus) | `url` `levels` `channel` `emoji` `username`|\n| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | `address` `facility` `extra`|\n| [Mail](https://github.com/zbindenren/logrus_mail) | `app-name` `host` `port` `from` `to` `username` `password`|\n| File | `filename` `max-lines` `max-size` `daily` `max-days` `rotate` `level`|\n| BearyChat | `url` `levels` `channel` `user` `markdown` `async`|\n| [LFSHook](https://github.com/rifflock/lfshook) | `path-map { error = \"logs/error.log\" ... }`|\n| sls | [README](https://github.com/gogap/logrus_mate/blob/master/hooks/sls/README.md)|\n\nWhen we need use above hooks, we need import these package as follow:\n\n```go\nimport _ \"github.com/gogap/logrus_mate/hooks/syslog\"\nimport _ \"github.com/gogap/logrus_mate/hooks/mail\"\n```\n\nIf you want write your own hook, you just need todo as follow:\n\n```go\npackage myhook\n\nimport (\n    \"github.com/gogap/logrus_mate\"\n)\n\ntype MyHookConfig struct {\n    Address  string\n}\n\nfunc init() {\n    logrus_mate.RegisterHook(\"myhook\", NewMyHook)\n}\n\nfunc NewMyHook(config logrus_mate.Configuration) (hook logrus.Hook, err error) {\n    conf := MyHookConfig{}\n    if config!=nil {\n        conf.Address = config.GetString(\"address\")\n    }\n\n    // write your hook logic code here\n\n    return\n}\n```\n\n\n#### Formatters\n\n**internal formatters:**\n\n| Formatter  | Options |Output Example |\n| ----- | ----------- | ----------- |\n|null|||\n|text|`force-colors` `disable-colors` `disable-timestamp` `full-timestamp` `timestamp-format` `disable-sorting`|DEBU[0000] Hello Default Logrus Mate|\n|json|`timestamp-format`|{\"level\":\"info\",\"msg\":\"Hello, I am A Logger from jack\",\"time\":\"2015-10-18T21:24:19+08:00\"}|\n\n**3rd formatters:**\n\n| Formatter  | Output Example |\n| ----- | ----------- |\n|logstash [**Removed**]||\n\nWhen we need use 3rd formatter, we need import these package as follow:\n\n```go\nimport _ \"github.com/gogap/logrus_mate/formatters/xxx\"\n```\n\nIf you want write your own formatter, you just need todo as follow:\n\n```go\npackage myformatter\n\nimport (\n    \"github.com/gogap/logrus_mate\"\n)\n\ntype MyFormatterConfig struct {\n    Address  string `json:\"address\"`\n}\n\nfunc init() {\n    logrus_mate.RegisterFormatter(\"myformatter\", NewMyFormatter)\n}\n\nfunc NewMyFormatter(config logrus_mate.Configuration) (formatter logrus.Formatter, err error) {\n    conf := MyFormatterConfig{}\n    if config!=nil {\n        conf.Address=config.GetString(\"address\")\n    }\n\n    // write your formatter logic code here\n\n    return\n}\n```\n\n#### Writers\n\n**internal writers (output):**\n\n- stdout\n- stderr\n- null\n\n**3rd writers:**\n\n| Writer  | Description |\n| ----- | ----------- |\n|redisio| just for demo, it will output into redis, the key type is list|\n|[rotatelogs](https://github.com/lestrrat-go/file-rotatelogs)| write log to file , configs: `clock` `location` `link-name` `rotation-time` `max-age`|\n\nWhen we need use 3rd writer, we need import these package as follow:\n\n```go\nimport _ \"github.com/gogap/logrus_mate/writers/redisio\"\n```\n\nIf you want write your own writer, you just need todo as follow:\n\n```go\npackage mywriter\n\nimport (\n    \"io\"\n\n    \"github.com/gogap/logrus_mate\"\n)\n\ntype MyWriterConfig struct {\n    Address  string `json:\"address\"`\n}\n\nfunc init() {\n    logrus_mate.RegisterWriter(\"mywriter\", NewMyWriter)\n}\n\nfunc NewMyWriter(config logrus_mate.Configuration) (writer io.Writer, err error) {\n    conf := MyWriterConfig{}\n    if config!=nil {\n        conf.Address=config.GetString(\"address\")\n    }\n\n    // write your writer logic code here\n\n    return\n}\n```\n\n#### Config Provider\n\nThe default config provider is `HOCON`, you could use your own config provider, just implement the following interface{}\n\n```go\ntype ConfigurationProvider interface {\n    LoadConfig(filename string) Configuration\n    ParseString(cfgStr string) Configuration\n}\n\ntype Configuration interface {\n    GetBoolean(path string, defaultVal ...bool) bool\n    GetByteSize(path string) *big.Int\n    GetInt32(path string, defaultVal ...int32) int32\n    GetInt64(path string, defaultVal ...int64) int64\n    GetString(path string, defaultVal ...string) string\n    GetFloat32(path string, defaultVal ...float32) float32\n    GetFloat64(path string, defaultVal ...float64) float64\n    GetTimeDuration(path string, defaultVal ...time.Duration) time.Duration\n    GetTimeDurationInfiniteNotAllowed(path string, defaultVal ...time.Duration) time.Duration\n    GetBooleanList(path string) []bool\n    GetFloat32List(path string) []float32\n    GetFloat64List(path string) []float64\n    GetInt32List(path string) []int32\n    GetInt64List(path string) []int64\n    GetByteList(path string) []byte\n    GetStringList(path string) []string\n    GetConfig(path string) Configuration\n    WithFallback(fallback Configuration)\n    HasPath(path string) bool\n    Keys() []string\n}\n```\n\n**set your own config provider**\n\n```go\npackage main\n\nimport (\n    \"github.com/gogap/config\"\n    \"github.com/gogap/logrus_mate\"\n    \"github.com/sirupsen/logrus\"\n)\n\nfunc main() {\n    mate, _ := logrus_mate.NewLogrusMate(\n        logrus_mate.ConfigString(\n            `{ mike {formatter.name = \"json\"} }`,\n        ),\n        logrus_mate.ConfigFile(\n            \"mate.conf\", // { mike {formatter.name = \"text\"} }\n        ),\n        logrus_mate.ConfigProvider(\n            \u0026config.HOCONConfigProvider{}, // this is defualt provider if you did not configurate\n        ),\n    )\n\n    mate.Hijack(\n        logrus.StandardLogger(),\n        \"mike\",\n    )\n\n    logrus.Println(\"hello std logger is hijack by mike\")\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgogap%2Flogrus_mate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgogap%2Flogrus_mate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgogap%2Flogrus_mate/lists"}