{"id":21717196,"url":"https://github.com/johan-bolmsjo/rainbow","last_synced_at":"2025-07-19T16:02:40.305Z","repository":{"id":57584422,"uuid":"174871935","full_name":"johan-bolmsjo/rainbow","owner":"johan-bolmsjo","description":"Configurable log file colorer that act as a stream processor.","archived":false,"fork":false,"pushed_at":"2021-04-17T11:23:48.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T19:09:51.489Z","etag":null,"topics":["colors","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/johan-bolmsjo.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":"2019-03-10T19:40:04.000Z","updated_at":"2022-03-06T18:04:32.000Z","dependencies_parsed_at":"2022-09-13T07:50:26.176Z","dependency_job_id":null,"html_url":"https://github.com/johan-bolmsjo/rainbow","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johan-bolmsjo%2Frainbow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johan-bolmsjo%2Frainbow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johan-bolmsjo%2Frainbow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johan-bolmsjo%2Frainbow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johan-bolmsjo","download_url":"https://codeload.github.com/johan-bolmsjo/rainbow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244681677,"owners_count":20492822,"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":["colors","logging"],"created_at":"2024-11-26T01:15:37.797Z","updated_at":"2025-03-20T20:09:35.559Z","avatar_url":"https://github.com/johan-bolmsjo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rainbow\n\nRainbow is a log file colorer that act as a stream processor. Match and action\nrules are applied according to configuration to each line read from stdin,\noutputting them to stdout.\n\nOne instance where this tool may be useful is when developing applications that\nlog lots of data to traditional log files, maybe an embedded system. When you\nare looking for certain patterns, coloring may greatly speed up troubleshooting.\nA custom configuration is quickly created to troubleshoot particular issues.\n\n## Design Goals\n\n* Low latency, output buffering is per line only.\n* Good performance. Care has been taken to minimize memory allocations.\n  Currently most time is spent in Go's regexp package.\n* Easy to create customized log filters.\n\n## Usage\n\nConfiguration files are searched for in `~/.config/rainbow/` with the suffix\n`.rainbow` automatically added. e.g. the command `rainbow example` would try to\nload the config file `~/.config/rainbow/example.rainbow`. Alternatively a full\npath to a config file can be specified using the `-config` flag.\n\n### Command-line Flags\n\n    -help         Show help\n    -color        Force color for non-TTY output\n    -config FILE  Use config FILE\n    CONFIG        Use config from ~/.config/rainbow/CONFIG.rainbow \n\n### Example Usage\n\n    go build\n    ./rainbow -config testdata/config/example.rainbow \u003c testdata/logs/example.log\n\nA rather silly example that gives an idea about what the tool can do.\n\n![Screenshot](screenshot.png)\n\n## Configuration\n\nThe basic configuration primitives (strings, lists, association lists) are\ndescribed at \u003chttps://github.com/johan-bolmsjo/saft/blob/master/README.md\u003e.\nDetails specific to rainbow follows.\n\n### Example Configuration\n\nAn example configuration first, coloring \"testdata/config/example.rainbow\".\n\n    {\n        filter: {\n            name: logLevel\n    \n            filter: {\n                regexp: `\\d \\[((EMERG|ALERT|CRIT)|(ERROR)|(WARN))\\]`\n                properties: {\n                    2: { // emerg...\n                        color:     white\n                        bgcolor:   red\n                        modifiers: bold\n                    }\n                    3: { // error\n                        color:   white\n                        bgcolor: red\n                    }\n                    4: { // warn\n                        color:   black\n                        bgcolor: yellow\n                    }\n                }\n            }\n            // Color whole INFO logs gray as base color.\n            filter: {\n                name:   info\n                regexp: `^([\\d-:\\. ]+ \\[INFO\\].*)$`\n                properties: {\n                    1: {\n                        color: iblack\n                    }\n                }\n            }\n            // Color whole DEBUG logs cyan as base color.\n            filter: {\n                name:   debug\n                regexp: `^([\\d-:\\. ]+ \\[DEBUG\\].*)$`\n                properties: {\n                    1: {\n                        color: cyan\n                    }\n                }\n            }\n        }\n    \n        filter: {\n            name:   time\n            regexp: `^\\d{4}-\\d{2}-\\d{2} (\\d{2}:\\d{2}:\\d{2})`\n        }\n        filter: {\n            name:       timeHighlight\n            regexpFrom: time\n            properties: {\n                1: {\n                    modifiers: bold\n                }\n            }\n        }\n        filter: {\n            name:   domain\n            regexp: `\\[\\w+\\]\\s+(\\w+):`\n            properties: {\n                1: {\n                    modifiers: bold\n                }\n            }\n        }\n        filter: {\n            name:   variable\n            regexp: `([\\w]+)=`\n            properties: {\n                1: {\n                    modifiers: bold\n                }\n            }\n        }\n    \n        apply: {\n            filters: [time logLevel]\n        }\n        apply: {\n            cond:    [and [filter-match? time]\n                          [not [equal? [filter-result time 0] [filter-result time 1]]]]\n            filters: timeHighlight\n        }\n        apply: {\n            cond:    [not [filter-match? logLevel/info logLevel/debug]]\n            filters: domain\n        }\n        apply: {\n            filters: variable\n        }\n    }\n\n### Filters\n\n`filter: { ... }`\n\nFilters specify line matching in the form of a regexp and what coloring to\nperform uppon match. When an executed filter matches a line the fact that it\nmatched and the result of the match is saved. The match status can be used to\nimplement primitive flow control for what filters are to be applied.\n\nFilters can be nested to group filters to apply. Named nested filters can be\nreferred to using '/' as path separator.\n\n#### Parameters\n\n    name: NAME\n      Optional filter name to be able to apply or reference filter.\n\n    regexp: REGEXP\n      Regular expression of filter.\n\n    regexpFrom: REFERENCE\n      Use regexp defined by other filter. The match result is reused\n      if the regexp has already been executed by the referenced filter.\n\n    properties: { REGEXP_GROUP: { PROPERTIES } }\n      Properties to apply to individually matched regexp groups.\n\n    filter: { ... }\n      Nested filters\n\n#### Parameter Values\n\n    NAME:\n      May not contain '/' as it is used to reference nested filters.\n\n    REGEXP:\n      See https://golang.org/pkg/regexp/syntax/ for syntax.\n\n    REFERENCE:\n      Reference to named filter using '/' as nested filter separator.\n      e.g. 'logLevel/debug'.\n\n    REGEXP_GROUP:\n      Positive integer value identifying the matched regexp group counting\n      from 1. Groups are counted from the left with each opening parenthesis.\n\n    PROPERTIES:\n      See [Filter Properties]\n\n### Filter Properties\n\nRegexp match properties.\n\n#### Parameters\n\n    color: COLOR\n      Foreground color.\n\n    bgcolor: COLOR\n      Background color.\n\n    modifiers: MODIFIER | [MODIFIER ...]\n      One or more modifiers.\n\n#### Parameter Values\n\n    COLOR:\n       black  red  green  yellow  blue  magenta  cyan  white\n      iblack ired igreen iyellow iblue imagenta icyan iwhite\n\n      ANSI defines 8 terminal colors and intense versions of the same. Intense\n      black yields a grayish color. Intense colors are prefixed with \"i\".\n\n    MODIFIER:\n      bold underline reverse blink\n\n### Applying Filters\n\n`apply: { ... }`\n\nThe order in which filters are applied are specified by apply clauses.\n\n#### Parameters\n\n    cond: EXPR\n      A lisp like expression that must evaluate to true for the apply clause\n      to be applied. See [Condition Expression].\n\n    filters: FILTER | [FILTER ...]\n      One ore more filters to apply if the condition evaluated to true.\n\n#### Condition Expression\n\nA couple of built in functions are available to build an expression that\nevaluates to true or false.\n\nFunctions are lisp like in that the first list element is the function and\nthe following elements its arguments.\n\n    [not arg]\n      Evaluates to true if arg is considered false, else false\n\n    [and arg...]\n      Evaluates to true with zero arguments.\n      Evaluates to the first argument considered false or the last argument.\n\n    [or arg...]\n      Evaluates to false with zero arguments.\n      Evaluates to the first argument considered true or the last argument.\n\n    [equal? arg1 arg2]\n      Evaluates to true if arg1 and arg2 are considered equal, else false.\n\n    [filter-match? filterName...]\n      Evaluates to true if any of the listed filters regexp matched, else false.\n\n    [filter-result filterName idx]\n      Get filter regexp match result as a list of strings of all matched regexp\n      groups, idx=0 is current match, idx=1 is previous\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohan-bolmsjo%2Frainbow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohan-bolmsjo%2Frainbow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohan-bolmsjo%2Frainbow/lists"}