{"id":22763261,"url":"https://github.com/darealfreak/colored-nested-formatter","last_synced_at":"2025-03-30T09:41:38.512Z","repository":{"id":45965816,"uuid":"215595558","full_name":"DaRealFreak/colored-nested-formatter","owner":"DaRealFreak","description":"human readable log formatter for the logrus library","archived":false,"fork":false,"pushed_at":"2023-03-23T21:58:05.000Z","size":31,"stargazers_count":0,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T11:44:43.617Z","etag":null,"topics":[],"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/DaRealFreak.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":"2019-10-16T16:34:59.000Z","updated_at":"2021-07-19T13:08:30.000Z","dependencies_parsed_at":"2024-06-20T01:39:54.568Z","dependency_job_id":"17c9cfda-f468-4500-a0a5-3c9f394e6826","html_url":"https://github.com/DaRealFreak/colored-nested-formatter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaRealFreak%2Fcolored-nested-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaRealFreak%2Fcolored-nested-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaRealFreak%2Fcolored-nested-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaRealFreak%2Fcolored-nested-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaRealFreak","download_url":"https://codeload.github.com/DaRealFreak/colored-nested-formatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301961,"owners_count":20755512,"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":[],"created_at":"2024-12-11T11:07:50.588Z","updated_at":"2025-03-30T09:41:38.495Z","avatar_url":"https://github.com/DaRealFreak.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Colored Nested Logrus Formatter\r\n[![Build Status](https://travis-ci.com/DaRealFreak/colored-nested-formatter.svg?branch=master)](https://travis-ci.com/DaRealFreak/colored-nested-formatter) [![Go Report Card](https://goreportcard.com/badge/github.com/DaRealFreak/colored-nested-formatter)](https://goreportcard.com/report/github.com/DaRealFreak/colored-nested-formatter) [![Coverage Status](https://coveralls.io/repos/github/DaRealFreak/colored-nested-formatter/badge.svg?branch=master)](https://coveralls.io/github/DaRealFreak/colored-nested-formatter?branch=master) ![License](https://img.shields.io/github/license/DaRealFreak/colored-nested-formatter )\r\n\r\nHuman readable log formatter for the logrus library. Option to define custom colors for specific field matches.\r\n\r\n## Usage\r\nYou can either register it for every log or create your new log instance and use the SetFormatter function of the logrus Log.\r\n\r\nExample code:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\tformatter \"github.com/DaRealFreak/colored-nested-formatter\"\r\n\t\"github.com/sirupsen/logrus\"\r\n\t\"time\"\r\n)\r\n\r\nfunc main() {\r\n\tlog := logrus.New()\r\n\tlog.SetFormatter(\u0026formatter.Formatter{\r\n\t\tDisableColors:            false,\r\n\t\tForceColors:              false,\r\n\t\tDisableTimestamp:         false,\r\n\t\tUseUppercaseLevel:        false,\r\n\t\tUseTimePassedAsTimestamp: false,\r\n\t\tTimestampFormat:          time.StampMilli,\r\n\t\tPadAllLogEntries:         true,\r\n\t})\r\n\r\n\tformatter.AddFieldMatchColorScheme(\"color\", \u0026formatter.FieldMatch{\r\n\t\tValue: \"blue\",\r\n\t\tColor: \"232:33\",\r\n\t})\r\n\tformatter.AddFieldMatchColorScheme(\"moreColorFields\", \u0026formatter.FieldMatch{\r\n\t\tValue: \"green\",\r\n\t\tColor: \"232:34\",\r\n\t})\r\n\r\n\tlog.Info(\"normal info log entry\")\r\n\tlog.WithField(\"color\", \"unregistered\").Infof(\"normal colored not nested info log entry\")\r\n\tlog.WithField(\"color\", \"blue\").Info(\"blue colored nested info log entry\")\r\n\tlog.WithFields(logrus.Fields{\"color\": \"blue\", \"moreColorFields\": \"green\"}).Info(\r\n\t\t\"blue and green colored nested info log entry\",\r\n\t)\r\n}\r\n```\r\n\r\nThe above code will output this:\r\n![Example Output](example_output.png)\r\n\r\n\r\n## Configuration\r\nYou have multiple configuration options for the formatter for whatever use case you need it for:\r\n```\r\ntype Formatter struct {\r\n\t// timestamp formatting, default is time.RFC3339\r\n\tTimestampFormat string\r\n\t// color schema for messages\r\n\tColorSchema *ColorSchema\r\n\t// no colors\r\n\tDisableColors bool\r\n\t// no check for TTY terminal\r\n\tForceColors bool\r\n\t// no timestamp\r\n\tDisableTimestamp bool\r\n\t// false -\u003e time passed, true -\u003e timestamp\r\n\tUseTimePassedAsTimestamp bool\r\n\t// false -\u003e info, true -\u003e INFO\r\n\tUseUppercaseLevel bool\r\n\t// reserves space for all log entries for all registered matches\r\n\tPadAllLogEntries bool\r\n}\r\n```\r\n\r\n## Development\r\nWant to contribute? Great!  \r\nI'm always glad hearing about bugs or pull requests.\r\n\r\n## License\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarealfreak%2Fcolored-nested-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarealfreak%2Fcolored-nested-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarealfreak%2Fcolored-nested-formatter/lists"}