{"id":17754829,"url":"https://github.com/sponja23/winston-stream-wrapper","last_synced_at":"2026-05-15T20:32:24.475Z","repository":{"id":65350021,"uuid":"588825015","full_name":"sponja23/winston-stream-wrapper","owner":"sponja23","description":"A streamable wrapper for Winston loggers ","archived":false,"fork":false,"pushed_at":"2024-03-25T05:55:47.000Z","size":110,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T10:04:56.005Z","etag":null,"topics":["logging","nodejs","plugin","stream","typescript","winston"],"latest_commit_sha":null,"homepage":"","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/sponja23.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":"2023-01-14T06:04:31.000Z","updated_at":"2024-10-27T13:12:13.000Z","dependencies_parsed_at":"2024-03-25T06:43:55.922Z","dependency_job_id":"20e31e0a-1e42-470b-8d93-fae18ddf9b0d","html_url":"https://github.com/sponja23/winston-stream-wrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sponja23/winston-stream-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sponja23%2Fwinston-stream-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sponja23%2Fwinston-stream-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sponja23%2Fwinston-stream-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sponja23%2Fwinston-stream-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sponja23","download_url":"https://codeload.github.com/sponja23/winston-stream-wrapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sponja23%2Fwinston-stream-wrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33078899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["logging","nodejs","plugin","stream","typescript","winston"],"created_at":"2024-10-26T14:22:42.663Z","updated_at":"2026-05-15T20:32:24.453Z","avatar_url":"https://github.com/sponja23.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# winston-stream-wrapper\n\n[![npm](https://img.shields.io/npm/v/winston-stream-wrapper)](https://www.npmjs.com/package/winston-stream-wrapper)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/sponja23/winston-stream-wrapper/build.yml?branch=main)\n[![codecov](https://codecov.io/gh/sponja23/winston-stream-wrapper/branch/main/graph/badge.svg?token=YYCQZM57DY)](https://codecov.io/gh/sponja23/winston-stream-wrapper)\n\nThis package provides a type-safe wrapper for [winston](https://github.com/winstonjs/winston) `Logger` instances that allows them to easily be used as a [Node.js `WritableStream`](https://nodejs.org/api/stream.html).\n\n## Motivation\n\nI wrote this package because I needed to pipe a subprocess' output to a `Logger` instance. I tried using [`winston-stream`](https://www.npmjs.com/package/winston-stream), but it had a few issues around buffered streams that are solved by the `splitLines` option in this package.\n\n## Installation\n\n```bash\nnpm install winston-stream-wrapper\n```\n\n## Usage\n\nThe following example shows how to pipe a subprocess' `stdout` and `stderr` to a `Logger` instance:\n\n```ts\nimport { spawn } from \"child_process\";\nimport { createLogger, format, transports } from 'winston';\n\nimport LogStreamWrapper from 'winston-stream-wrapper';\n\nconst logger = createLogger({\n    format: format.combine(\n        format.timestamp(),\n        format.json(),\n    ),\n    transports: [\n        new transports.Console(),\n    ],\n});\n\nconst infoStream = new LogStreamWrapper(logger, {\n    level: 'info',\n    splitLines: true,\n});\n\nconst errorStream = new LogStreamWrapper(logger, {\n    level: 'error',\n    splitLines: true,\n});\n\nconst subprocess = spawn('some-command', ['some', 'args']);\n\n// This will log each line of the subprocess' output as a separate log message.\nsubprocess.stdout.pipe(infoStream);\nsubprocess.stderr.pipe(errorStream);\n```\n\n## API\n\nThe package exports a single class, `LogStreamWrapper`, which is a `WritableStream` that can be used to pipe data to a `Logger` instance.\n\n### `LogStreamWrapper`\n\n```ts\nclass LogStreamWrapper extends Writable {\n    constructor(logger: Logger, options: LogStreamWrapperOptions);\n}\n```\n\n#### Options\n\nThe `LogStreamWrapper` constructor takes an options object with the following properties:\n\n* `level`: The level to log messages at.\n* `splitLines`: Whether to split the stream's input into separate log messages on newlines. If `false`, every chunk of data will be logged as a single log message. Defaults to `true`.\n* `skipEmptyLines`: Whether to skip empty lines when `splitLines` is `true`. Defaults to `true`.\n* `lineSeparator`: The line separator to use when `splitLines` is `true`. Defaults to `\\n`.\n\n## Issues\n\nIf you find any issues with this package, please [open an issue](https://github.com/sponja23/winston-stream-wrapper/issues) on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsponja23%2Fwinston-stream-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsponja23%2Fwinston-stream-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsponja23%2Fwinston-stream-wrapper/lists"}