{"id":17188225,"url":"https://github.com/jclem/logfmt2","last_synced_at":"2025-04-13T19:13:16.937Z","repository":{"id":46940739,"uuid":"150499628","full_name":"jclem/logfmt2","owner":"jclem","description":"A logfmt encoder and decoder","archived":false,"fork":false,"pushed_at":"2023-01-07T03:59:21.000Z","size":813,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-14T02:31:58.451Z","etag":null,"topics":["logfmt","logging"],"latest_commit_sha":null,"homepage":"https://npm.im/@jclem/logfmt2","language":"TypeScript","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/jclem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-26T22:59:33.000Z","updated_at":"2021-10-20T18:38:29.000Z","dependencies_parsed_at":"2023-02-06T11:15:41.548Z","dependency_job_id":null,"html_url":"https://github.com/jclem/logfmt2","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jclem%2Flogfmt2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jclem%2Flogfmt2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jclem%2Flogfmt2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jclem%2Flogfmt2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jclem","download_url":"https://codeload.github.com/jclem/logfmt2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766746,"owners_count":21158301,"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":["logfmt","logging"],"created_at":"2024-10-15T01:08:26.801Z","updated_at":"2025-04-13T19:13:16.915Z","avatar_url":"https://github.com/jclem.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logfmt2\n\n[![](https://github.com/jclem/logfmt2/workflows/Test%20%26%20Benchmark/badge.svg)](https://github.com/jclem/logfmt2/actions)\n\nlogfmt2 (which is based on the original [logfmt](https://github.com/csquared/node-logfmt) and the original [blog post](https://brandur.org/logfmt)) is a module for encoding objects into the logfmt format and decoding them again.\n\n## Install\n\n```\nnpm install @jclem/logfmt2\n```\n\n## Build\n\n```\nscript/build\n```\n\n## Publish\n\nThe `script/publish` script cleans the build directory, builds the project, and then runs `npm publish`.\n\n```\nscript/publish\n```\n\n## Usage\n\n```javascript\nconst {Logger, encode, decode} = require('@jclem/logfmt2')\n\nconsole.log(encode({foo: 'bar'})) // foo=bar\nconsole.log(decode('foo=bar')) // {foo: 'bar'}\n\n// Use the static `Logger.log` to stdout\nLogger.log({foo: 'bar'}) // logs \"foo=bar\"\n\n// Create a logger to maintain a logging context\nconst logger = new Logger({ns: 'my-app'})\nlogger.log({foo: 'bar'}) // logs \"ns=my-app foo=bar\"\n\n// Add timers\nlogger.time('elapsedMs')\n// Wait 50ms\nlogger.log({foo: 'bar'}) // logs \"ns=my-app elapsedMs=50 foo=bar\"\n// Wait 50ms\nlogger.log({foo: 'bar'}) // logs \"ns=my-app elapsedMs=100 foo=bar\"\n\n// Add (mutate) the logger context\nlogger.appendContext({new_context: 'hello'})\nlogger.log({foo: 'bar'}) // logs \"ns=my-app new_context=hello elapsedMs=100 foo=bar\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjclem%2Flogfmt2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjclem%2Flogfmt2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjclem%2Flogfmt2/lists"}