{"id":20319493,"url":"https://github.com/yakkomajuri/structlog","last_synced_at":"2025-04-11T18:13:09.283Z","repository":{"id":43165847,"uuid":"467879123","full_name":"yakkomajuri/structlog","owner":"yakkomajuri","description":"A lightweight structured logging tool for Node.js without any dependencies.","archived":false,"fork":false,"pushed_at":"2022-03-15T16:25:57.000Z","size":398,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T18:13:03.170Z","etag":null,"topics":["javascript","javascript-library","log","logger","logging","nodejs","npm","npm-package","structured-logging"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/structlog","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/yakkomajuri.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":"2022-03-09T10:25:12.000Z","updated_at":"2023-02-15T04:17:50.000Z","dependencies_parsed_at":"2022-08-29T14:43:32.165Z","dependency_job_id":null,"html_url":"https://github.com/yakkomajuri/structlog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakkomajuri%2Fstructlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakkomajuri%2Fstructlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakkomajuri%2Fstructlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakkomajuri%2Fstructlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yakkomajuri","download_url":"https://codeload.github.com/yakkomajuri/structlog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248456373,"owners_count":21106604,"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":["javascript","javascript-library","log","logger","logging","nodejs","npm","npm-package","structured-logging"],"created_at":"2024-11-14T18:47:07.899Z","updated_at":"2025-04-11T18:13:09.254Z","avatar_url":"https://github.com/yakkomajuri.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# structlog\n\nA lightweight structured logging tool for Node.js without any dependencies.\n\n## Example\n\nBy default this tool will generate logs like the following:\n\n```\n2022-03-09T19:57:48.962Z [error] i'm an error [/structlog/foo.js:5] thread=MAIN logId=017f705b-4200-0002-1101-720541fa117c \n2022-03-09T19:57:48.963Z [warn] i'm a warning [/structlog/foo.js:6] thread=MAIN logId=017f705b-4200-0000-e4a6-f1df2ca4f248\n```\n\nHowever, you can configure both the log and timestamp formats.\n## Usage\n\nTo use this logging tool, all you need to do is install it:\n\n```sh\nyarn add structlog\n```\n\nAnd use it like so:\n\n```js\nimport { logger } from 'structlog'\n\nlogger.error('error!')\n```\n\nImporting `logger` will give you a ready-made instance of `StructuredLogger` with the default config, so you don't need to instantiate a new logger instance each time or pass down references to an instance.\n\nHowever, you can configure options by instantiating `StructuredLogger` yourself, like so:\n\n```js\nimport { StructuredLogger } from 'structlog'\n\nconst logger = new StructuredLogger({ timestampFormat: 'unix' })\n```\n\n### Options \n\nYou can configure the following options by passing them in an object as a parameter when creating `StructuredLogger` :\n\n| Option | Default value | Accepted values | Description |\n| :--: | :--: | :--: | :--: | \n| `timestampFormat` | `'iso'` | `'iso'` , `'gmt'`, `'unix'`, `'timestring'` ,`'localestring'` | Timestamp format to use. |\n| `logFormat` | `'{timestamp} [{type}] {message} [{path}] {tags}'` | Any `string` | Log format to use `{}` to define variables. Accepted variables: `timestamp`, `type`, `message`, `path`, `tags`. |\n| `pathFormat` | `'{filePath}:{lineNumber}'` | Any `string` | Format to use for the `path` component of the log. Use `{}` to define variables. Accepted variables: `filePath`, `lineNumber`, `functionName`, `methodName`, `typeName`. |\n| `useColors` | `false` | `true`, `false` | Whether logs should be printed with colors according to the type (e.g. error = red). |\n| `useThreadTagsExtension` | `false` | `true`, `false` | An extension that automatically adds a `thread` tag to the log specifying what thread the log happened in. |\n| `useLogIdExtension` | `false` | `true`, `false` | An extension that automatically adds a `logId` tag to the log, with a unique ID as its value. |\n| `pathStackDepth` | `0` | Any `number` | (_Advanced_) Level of depth to determine the path portion of the log from. For example, if you write a wrapper over the logger, set this to 1 so that the path will reflect the code that called your wrapper, rather than the wrapper itself.  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakkomajuri%2Fstructlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyakkomajuri%2Fstructlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakkomajuri%2Fstructlog/lists"}