{"id":20594373,"url":"https://github.com/loderunner/winston-transport-vscode","last_synced_at":"2025-03-06T14:43:57.109Z","repository":{"id":221678480,"uuid":"755066383","full_name":"loderunner/winston-transport-vscode","owner":"loderunner","description":"A Winston logger transport for VS Code extension development","archived":false,"fork":false,"pushed_at":"2025-01-27T10:55:31.000Z","size":608,"stargazers_count":2,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T09:11:08.347Z","etag":null,"topics":["log","logger","logging","logs","microsoft","transport","vscode","vscode-extension","winston","winston-logger","winston-transport","winstonjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loderunner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2024-02-09T11:22:19.000Z","updated_at":"2024-11-12T10:46:13.000Z","dependencies_parsed_at":"2024-04-15T12:01:25.126Z","dependency_job_id":null,"html_url":"https://github.com/loderunner/winston-transport-vscode","commit_stats":null,"previous_names":["loderunner/winston-vscode","loderunner/winston-transport-vscode"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loderunner%2Fwinston-transport-vscode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loderunner%2Fwinston-transport-vscode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loderunner%2Fwinston-transport-vscode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loderunner%2Fwinston-transport-vscode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loderunner","download_url":"https://codeload.github.com/loderunner/winston-transport-vscode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241860002,"owners_count":20032319,"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":["log","logger","logging","logs","microsoft","transport","vscode","vscode-extension","winston","winston-logger","winston-transport","winstonjs"],"created_at":"2024-11-16T08:08:47.737Z","updated_at":"2025-03-06T14:43:57.085Z","avatar_url":"https://github.com/loderunner.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# winston-transport-vscode\n\nA [Winston](https://github.com/winstonjs/winston) logger transport for VS Code extension development.\n\n[![CircleCI](https://circleci.com/gh/loderunner/winston-transport-vscode.svg?style=shield)](https://app.circleci.com/pipelines/github/loderunner/winston-transport-vscode?branch=main)\n[![NPM](https://img.shields.io/npm/v/winston-transport-vscode)](https://www.npmjs.com/package/winston-transport-vscode)\n[![Apache-2.0](https://img.shields.io/npm/l/winston-transport-vscode)](https://choosealicense.com/licenses/apache-2.0/)\n\n---\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Transports](#transports)\n  - [OutputChannelTransport](#outputchanneltransport)\n  - [LogOutputChannelTransport](#logoutputchanneltransport)\n- [Levels](#levels)\n- [Format](#format)\n  - [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Installation\n\n```shell\nnpm install winston-transport-vscode\n```\n\n## Getting Started\n\nTo use Winston logger in your VS Code extension, create an output channel for\nyour extension, using the\n[VS Code API](https://code.visualstudio.com/api/references/vscode-api#window.createOutputChannel),\ncreate a Transport, giving it the output channel, and use that transport in your\nwinston logger instance.\n\n```js\n// 1. Require (or import)\nconst vscode = require('vscode');\nconst winston = require('winston');\nconst { LogOutputChannelTransport } = require('winston-transport-vscode');\n\n// 2. Create a Log Output Channel for your extension with the VS Code API\nconst outputChannel = vscode.window.createOutputChannel('My extension', {\n  log: true,\n});\n\n// 3. Create the Winston logger giving it the Log Output Channel\nconst logger = winston.createLogger({\n  level: 'trace', // Recommended: set the highest possible level\n  levels: LogOutputChannelTransport.config.levels, // Recommended: use predefined VS Code log levels\n  format: LogOutputChannelTransport.format(), // Recommended: use predefined format\n  transports: [new LogOutputChannelTransport({ outputChannel })],\n});\n\nlogger.info('Hello World!');\n```\n\n## Transports\n\nVS Code offers 2 types of output channels:\n\n- [`OutputChannel`](https://code.visualstudio.com/api/references/vscode-api#OutputChannel) -\n  a simple channel for plain text output\n- [`LogOutputChannel`](https://code.visualstudio.com/api/references/vscode-api#LogOutputChannel) -\n  an output channel dedicated to logging\n\n### OutputChannelTransport\n\nSend logs to an `OutputChannel` using the `OutputChannelTransport`\n\n```js\nconst vscode = require('vscode');\nconst winston = require('winston');\nconst { OutputChannelTransport } = require('winston-transport-vscode');\n\nconst { combine, timestamp, prettyPrint } = winston.format;\n\nconst outputChannel = vscode.window.createOutputChannel('My extension');\n\nconst transport = new OutputChannelTransport({\n  outputChannel,\n  format: combine(timestamp(), simple()),\n});\n\nconst logger = winston.createLogger({\n  transports: [transport],\n});\n\nlogger.info('Hello World!');\n```\n\n### LogOutputChannelTransport\n\nSend logs to a `LogOutputChannel` using the `LogOutputChannelTransport`.\n\n```js\nconst vscode = require('vscode');\nconst winston = require('winston');\nconst { LogOutputChannelTransport } = require('winston-transport-vscode');\n\nconst outputChannel = vscode.window.createOutputChannel('My extension', {\n  log: true,\n});\n\nconst logger = winston.createLogger({\n  level: 'trace',\n  levels: LogOutputChannelTransport.config.levels,\n  format: LogOutputChannelTransport.format(),\n  transports: [new LogOutputChannelTransport({ outputChannel })],\n});\n\nlogger.info('Hello World!');\n```\n\nIt is recommended to set the logger's level to the highest possible level\n(`trace`), as VS Code's LogOutputChannel supports its own [log level filtering](https://code.visualstudio.com/updates/v1_73#_setting-log-level-per-output-channel).\n\n## Levels\n\nVS Code's `LogOutputChannel` supports a dedicated set of log levels that differs\nfrom Winston's default configuration. To use VS Code log levels with Winston,\n`winston-transport-vscode` provides a levels configuration.\n\nThe log levels are as follows:\n\n- error - `0`\n- warn - `1`\n- info - `2`\n- debug - `3`\n- trace - `4`\n\nUse `LogOutputChannelTransport.config.levels` when configuring your logger.\n\n```js\nconst logger = winston.createLogger({\n  level: 'trace',\n\n  // winston-transport-vscode levels configuration\n  levels: LogOutputChannelTransport.config.levels,\n\n  format: LogOutputChannelTransport.format(),\n  transports: [new LogOutputChannelTransport({ outputChannel })],\n});\n```\n\n## Format\n\n`winston-transport-vscode` provides a built-in formatter that easily integrates\nwith `LogOutputChannel`. `LogOutputChannelTransport.format` supports structured\nlogging for contextual value while outputting a more human-readable format than\nJSON.\n\n```js\nconst fmt = LogOutputChannelTransport.format();\n\nfmt.transform({ level: 'info', message: 'Hello World!', extra: 'value' });\n// {\n//   level: 'info',\n//   message: 'Hello World!',\n//   extra: 'info',\n//   [Symbol(level)]: 'info',\n//   [Symbol(message)]: 'Hello World! extra=\"value\"'\n// }\n\nfmt.transform({\n  level: 'info',\n  message: 'Hello World!',\n  nested: { values: { are: { supported: true } } },\n});\n// {\n//   level: 'info',\n//   message: 'Hello World!',\n//   nested: { values: { are: [Object] } },\n//   [Symbol(level)]: 'info',\n//   [Symbol(message)]: 'Hello World! nested.values.are.accepted=true'\n// }\n```\n\n### Usage\n\nUse `LogOutputChannelTransport.format` when configuring your logger.\n\n```js\nconst logger = winston.createLogger({\n  level: 'trace',\n  levels: LogOutputChannelTransport.config.levels,\n\n  // winston-transport-vscode format\n  format: LogOutputChannelTransport.format(),\n\n  transports: [new LogOutputChannelTransport({ outputChannel })],\n});\n\nlogger.info('Hello World!', { extra: 'value', nested: { value: 'too' } });\n// Output to log channel:\n// 2024-02-12 21:18:36.382 [info] Hello World! extra=\"value\" nested.value=\"too\"\n```\n\n## Contributing\n\nPRs and issues are welcome on this repository.\n\n## License\n\nCopyright 2024 Charles Francoise\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floderunner%2Fwinston-transport-vscode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floderunner%2Fwinston-transport-vscode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floderunner%2Fwinston-transport-vscode/lists"}