{"id":13413314,"url":"https://github.com/mgutz/logxi","last_synced_at":"2026-01-29T05:16:52.064Z","repository":{"id":28017987,"uuid":"31512899","full_name":"mgutz/logxi","owner":"mgutz","description":"A 12-factor app logger built for performance and happy development","archived":false,"fork":false,"pushed_at":"2020-04-14T15:56:24.000Z","size":7860,"stargazers_count":358,"open_issues_count":21,"forks_count":52,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-15T22:20:10.561Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mgutz.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-03-01T22:13:45.000Z","updated_at":"2025-05-13T21:06:30.000Z","dependencies_parsed_at":"2022-08-21T16:10:52.189Z","dependency_job_id":null,"html_url":"https://github.com/mgutz/logxi","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mgutz/logxi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgutz%2Flogxi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgutz%2Flogxi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgutz%2Flogxi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgutz%2Flogxi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgutz","download_url":"https://codeload.github.com/mgutz/logxi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgutz%2Flogxi/sbom","scorecard":{"id":639656,"data":{"date":"2025-08-11","repo":{"name":"github.com/mgutz/logxi","commit":"aebf8a7d67ab4625e0fd4a665766fef9a709161b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"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":"Code-Review","score":2,"reason":"Found 6/28 approved changesets -- score normalized to 2","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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: 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 8 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-21T10:20:23.870Z","repository_id":28017987,"created_at":"2025-08-21T10:20:23.870Z","updated_at":"2025-08-21T10:20:23.870Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28863377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"online","status_checked_at":"2026-01-29T02:00:06.714Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-07-30T20:01:37.496Z","updated_at":"2026-01-29T05:16:52.051Z","avatar_url":"https://github.com/mgutz.png","language":"Go","funding_links":[],"categories":["日志","Logging","日志记录","Go","Relational Databases","Logging 日志库","日誌","\u003cspan id=\"日志-logging\"\u003e日志 Logging\u003c/span\u003e"],"sub_categories":["Advanced Console UIs","Search and Analytic Databases","检索及分析资料库","SQL 查询语句构建库","高级控制台界面","交流","高級控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"\n![demo](https://github.com/mgutz/logxi/raw/master/images/demo.gif)\n\n# logxi\n\nlog XI is a structured [12-factor app](http://12factor.net/logs)\nlogger built for speed and happy development.\n\n*   Simpler. Sane no-configuration defaults out of the box.\n*   Faster. See benchmarks vs logrus and log15.\n*   Structured. Key-value pairs are enforced. Logs JSON in production.\n*   Configurable. Enable/disalbe Loggers and levels via env vars.\n*   Friendlier. Happy, colorful and developer friendly logger in terminal.\n*   Helpul. Traces, warnings and errors are emphasized with file, line\n    number and callstack.\n*   Efficient. Has level guards to avoid cost of building complex arguments.\n\n\n### Requirements\n\n    Go 1.3+\n\n### Installation\n\n    go get -u github.com/mgutz/logxi/v1\n\n### Getting Started\n\n```go\nimport \"github.com/mgutz/logxi/v1\"\n\n// create package variable for Logger interface\nvar logger log.Logger\n\nfunc main() {\n    // use default logger\n    who := \"mario\"\n    log.Info(\"Hello\", \"who\", who)\n\n    // create a logger with a unique identifier which\n    // can be enabled from environment variables\n    logger = log.New(\"pkg\")\n\n    // specify a writer, use NewConcurrentWriter if it is not concurrent\n    // safe\n    modelLogger = log.NewLogger(log.NewConcurrentWriter(os.Stdout), \"models\")\n\n    db, err := sql.Open(\"postgres\", \"dbname=testdb\")\n    if err != nil {\n        modelLogger.Error(\"Could not open database\", \"err\", err)\n    }\n\n    fruit := \"apple\"\n    languages := []string{\"go\", \"javascript\"}\n    if log.IsDebug() {\n        // use key-value pairs after message\n        logger.Debug(\"OK\", \"fruit\", fruit, \"languages\", languages)\n    }\n}\n```\n\nlogxi defaults to showing warnings and above. To view all logs\n\n    LOGXI=* go run main.go\n\n## Highlights\n\nThis logger package\n\n*   Is fast in production environment\n\n    A logger should be efficient and minimize performance tax.\n    logxi encodes JSON 2X faster than logrus and log15 with primitive types.\n    When diagnosing a problem in production, troubleshooting often means\n    enabling small trace data in `Debug` and `Info` statements for some\n    period of time.\n\n        # primitive types\n        BenchmarkLogxi          100000    20021 ns/op   2477 B/op    66 allocs/op\n        BenchmarkLogrus          30000    46372 ns/op   8991 B/op   196 allocs/op\n        BenchmarkLog15           20000    62974 ns/op   9244 B/op   236 allocs/op\n\n        # nested object\n        BenchmarkLogxiComplex    30000    44448 ns/op   6416 B/op   190 allocs/op\n        BenchmarkLogrusComplex   20000    65006 ns/op  12231 B/op   278 allocs/op\n        BenchmarkLog15Complex    20000    92880 ns/op  13172 B/op   311 allocs/op\n\n*   Is developer friendly in the terminal. The HappyDevFormatter\n    is colorful, prints file and line numbers for traces, warnings\n    and errors. Arguments are printed in the order they are coded.\n    Errors print the call stack.\n\n    `HappyDevFormatter` is not too concerned with performance\n    and delegates to JSONFormatter internally.\n\n*   Logs machine parsable output in production environments.\n    The default formatter for non terminals is `JSONFormatter`.\n\n    `TextFormatter` may also be used which is MUCH faster than\n    JSON but there is no guarantee it can be easily parsed.\n\n*   Has level guards to avoid the cost of building arguments. Get in the\n    habit of using guards.\n\n        if log.IsDebug() {\n            log.Debug(\"some \", \"key1\", expensive())\n        }\n\n*   Conforms to a logging interface so it can be replaced.\n\n        type Logger interface {\n            Trace(msg string, args ...interface{})\n            Debug(msg string, args ...interface{})\n            Info(msg string, args ...interface{})\n            Warn(msg string, args ...interface{}) error\n            Error(msg string, args ...interface{}) error\n            Fatal(msg string, args ...interface{})\n            Log(level int, msg string, args []interface{})\n\n            SetLevel(int)\n            IsTrace() bool\n            IsDebug() bool\n            IsInfo() bool\n            IsWarn() bool\n            // Error, Fatal not needed, those SHOULD always be logged\n        }\n\n*   Standardizes on key-value pair argument sequence\n\n    ```go\nlog.Debug(\"inside Fn()\", \"key1\", value1, \"key2\", value2)\n\n// instead of this\nlog.WithFields(logrus.Fields{\"m\": \"pkg\", \"key1\": value1, \"key2\": value2}).Debug(\"inside fn()\")\n```\n    logxi logs `FIX_IMBALANCED_PAIRS =\u003e` if key-value pairs are imbalanced\n\n    `log.Warn and log.Error` are special cases and return error:\n\n    ```go\nreturn log.Error(msg)               //=\u003e fmt.Errorf(msg)\nreturn log.Error(msg, \"err\", err)   //=\u003e err\n```\n\n*   Supports Color Schemes (256 colors)\n\n    `log.New` creates a logger that supports color schemes\n\n        logger := log.New(\"mylog\")\n\n    To customize scheme\n\n        # emphasize errors with white text on red background\n        LOGXI_COLORS=\"ERR=white:red\" yourapp\n\n        # emphasize errors with pink = 200 on 256 colors table\n        LOGXI_COLORS=\"ERR=200\" yourapp\n\n*   Is suppressable in unit tests\n\n    ```go\nfunc TestErrNotFound() {\n    log.Suppress(true)\n    defer log.Suppress(false)\n    ...\n}\n```\n\n\n\n## Configuration\n\n### Enabling/Disabling Loggers\n\nBy default logxi logs entries whose level is `LevelWarn` or above when\nusing a terminal. For non-terminals, entries with level `LevelError` and\nabove are logged.\n\nTo quickly see all entries use short form\n\n    # enable all, disable log named foo\n    LOGXI=*,-foo yourapp\n\nTo better control logs in production, use long form which allows\nfor granular control of levels\n\n    # the above statement is equivalent to this\n    LOGXI=*=DBG,foo=OFF yourapp\n\n`DBG` should obviously not be used in production unless for\ntroubleshooting. See `LevelAtoi` in `logger.go` for values.\nFor example, there is a problem in the data access layer\nin production.\n\n    # Set all to Error and set data related packages to Debug\n    LOGXI=*=ERR,models=DBG,dat*=DBG,api=DBG yourapp\n\n### Format\n\nThe format may be set via `LOGXI_FORMAT` environment\nvariable. Valid values are `\"happy\", \"text\", \"JSON\", \"LTSV\"`\n\n    # Use JSON in production with custom time\n    LOGXI_FORMAT=JSON,t=2006-01-02T15:04:05.000000-0700 yourapp\n\nThe \"happy\" formatter has more options\n\n*   pretty - puts each key-value pair indented on its own line\n\n    \"happy\" default to fitting key-value pair onto the same line. If\n    result characters are longer than `maxcol` then the pair will be\n    put on the next line and indented\n\n*   maxcol - maximum number of columns before forcing a key to be on its\n    own line. If you want everything on a single line, set this to high\n    value like 1000. Default is 80.\n\n*   context - the number of context lines to print on source. Set to -1\n    to see only file:lineno. Default is 2.\n\n\n### Color Schemes\n\nThe color scheme may be set with `LOGXI_COLORS` environment variable. For\nexample, the default dark scheme is emulated like this\n\n    # on non-Windows, see Windows support below\n    export LOGXI_COLORS=key=cyan+h,value,misc=blue+h,source=magenta,TRC,DBG,WRN=yellow,INF=green,ERR=red+h\n    yourapp\n\n    # color only errors\n    LOGXI_COLORS=ERR=red yourapp\n\nSee [ansi](http://github.com/mgutz/ansi) package for styling. An empty\nvalue, like \"value\" and \"DBG\" above means use default foreground and\nbackground on terminal.\n\nKeys\n\n*   \\*  - default color\n*   TRC - trace color\n*   DBG - debug color\n*   WRN - warn color\n*   INF - info color\n*   ERR - error color\n*   message - message color\n*   key - key color\n*   value - value color unless WRN or ERR\n*   misc - time and log name color\n*   source - source context color (excluding error line)\n\n#### Windows\n\nUse [ConEmu-Maximus5](https://github.com/Maximus5/ConEmu).\nRead this page about [256 colors](https://code.google.com/p/conemu-maximus5/wiki/Xterm256Colors).\n\nColors in PowerShell and Command Prompt _work_ but not very pretty.\n\n## Extending\n\nWhat about hooks? There are least two ways to do this\n\n*   Implement your own `io.Writer` to write to external services. Be sure to set\n    the formatter to JSON to faciliate decoding with Go's built-in streaming\n    decoder.\n*   Create an external filter. See `v1/cmd/filter` as an example.\n\nWhat about log rotation? 12 factor apps only concern themselves with\nSTDOUT. Use shell redirection operators to write to a file.\n\nThere are many utilities to rotate logs which accept STDIN as input. They can\ndo many things like send alerts, etc. The two obvious choices are Apache's `rotatelogs`\nutility and `lograte`.\n\n```sh\nyourapp | rotatelogs yourapp 86400\n```\n\n## Testing\n\n```\n# install godo task runner\ngo get -u gopkg.in/godo.v2/cmd/godo\n\n# install dependencies\ngodo install -v\n\n# run test\ngodo test\n\n# run bench with allocs (requires manual cleanup of output)\ngodo bench-allocs\n```\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgutz%2Flogxi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgutz%2Flogxi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgutz%2Flogxi/lists"}