{"id":43406377,"url":"https://github.com/aditosoftware/vscode-logging","last_synced_at":"2026-02-02T15:59:51.627Z","repository":{"id":256751659,"uuid":"856206053","full_name":"aditosoftware/vscode-logging","owner":"aditosoftware","description":"Simple logging for any VSCode extension","archived":false,"fork":false,"pushed_at":"2026-01-27T05:22:33.000Z","size":515,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-27T18:37:52.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@aditosoftware/vscode-logging","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/aditosoftware.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-12T07:11:12.000Z","updated_at":"2026-01-27T05:22:30.000Z","dependencies_parsed_at":"2024-11-18T05:28:01.232Z","dependency_job_id":"91b84805-4ac6-4b26-bd2a-dc14eb6a1f90","html_url":"https://github.com/aditosoftware/vscode-logging","commit_stats":null,"previous_names":["aditosoftware/vscode-logging"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aditosoftware/vscode-logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aditosoftware%2Fvscode-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aditosoftware%2Fvscode-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aditosoftware%2Fvscode-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aditosoftware%2Fvscode-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aditosoftware","download_url":"https://codeload.github.com/aditosoftware/vscode-logging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aditosoftware%2Fvscode-logging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29015064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T14:58:54.169Z","status":"ssl_error","status_checked_at":"2026-02-02T14:58:51.285Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2026-02-02T15:59:46.904Z","updated_at":"2026-02-02T15:59:51.614Z","avatar_url":"https://github.com/aditosoftware.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vscode-logging\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-logging\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-logging)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-logging\u0026metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-logging)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-logging\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-logging)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-logging\u0026metric=ncloc)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-logging)\n\nThis is used to add a simple and easy to use logging to any VS Code extension.\n\nThe key idea is that you do not need to call `vscode.window.showInformationMessage` (or similar methods) and do not need to write any additional logs, because this module will take care of everything.\n\nUncaught exceptions and uncaught rejects are logged as well.\n\n## Installation\n\nYou can install this dependency normally.\n\n```shell\nnpm install @aditosoftware/vscode-logging\n```\n\n## Usage\n\n### Initialization of the Logger\n\nThe logger needs to be initialized once in your `activate` method. The name given will be used for the [main logging file](#normal-log-file-namelog).\n\n```typescript\nexport function activate(context: vscode.ExtensionContext) {\n  Logger.initializeLogger(context, \"MyExtensionName\");\n}\n```\n\nAfter you have initialized the logger, you can get an instance and log.\n\n### Logging\n\nAfter the [initialization](#initialization-of-the-logger), you can get any logger instance via `Logger.getLogger()`. On this instance, you can call any log methods.\n\n#### How to log\n\n##### Basic logging\n\nThe logger can log to four different levels:\n\n- debug\n- info\n- warn\n- error\n\nAll four levels are written to the logging file, and all levels except debug are written [the output channel](#output-channel) and can [notify the user](#notify-the-user).\n\nA normal minimal logging call can look like this:\n\n```typescript\nimport { Logger } from \"@aditosoftware/vscode-logging\";\n\nconst logger: Logger = Logger.getLogger();\n\nlogger.debug({ message: \"my debug message\" });\nlogger.info({ message: \"my info message\" });\nlogger.warn({ message: \"my warn message\" });\nlogger.error({ message: \"my error message\" });\n```\n\n##### Logging from a webview\n\nYou can not call any logging methods from the webview directly. Instead, you need to transfer the log data to your extension and log it there. This minimal example assumes you know how to [transfer data from a webview to an extension](https://code.visualstudio.com/api/extension-guides/webview#passing-messages-from-a-webview-to-an-extension). Please be aware that transferring data can look a bit different from use case to use case.\n\nFor this use case, you can use `LoggingMessageWithLevel` to pass the data from the webview to the extension.\n\nIn your webview, you could transfer the message as following:\n\n```typescript\n// Build the logging message\nconst data: LoggingMessageWithLevel = {\n  // you need to give the level which yor message should have\n  level: \"info\",\n  message: \"my message from webview\",\n};\n\n// and post it to your extension\nvscodeApiWrapper.postMessage(data);\n```\n\nAll other parameters from `LoggingMessage` are also valid.\n\nThen you could receive the message in your extension and log via the `log` method.\n\n```typescript\nprivate _setWebviewMessageListener(webview: Webview) {\n  webview.onDidReceiveMessage(\n    (message: unknown) =\u003e {\n\n      // receive the data\n      const data: LoggingMessageWithLevel = message as LoggingMessageWithLevel;\n\n      // and log it\n      Logger.getLogger().log(data);\n    });\n}\n```\n\n#### Logging options\n\n##### Notify the user\n\nIf you want to notify the user about your message as well, you need to set the `notifyUser` flag.\nIf this flag is set to `true`, then the message will show as:\n\n- information message when logging to level info\n- warning message when logging to level warn\n- error message when logging to level error\n\nNote: It will not show any message to the user, if your level is debug.\n\nIf you don't set this option, then the user will not be notified.\n\n```typescript\nlogger.info({ message: \"my info message\", notifyUser: true });\n```\n\n##### Add stack traces to the log\n\nMessages that are logged on error level, can log a stack trace as well.\n\nThe `stack` information from the `error` will be logged. These information will only show in the log files and output channel and never in any notification to the user.\n\n```typescript\nimport { Logger } from \"@aditosoftware/vscode-logging\";\n\ntry {\n  // any operation that can cause error\n} catch (error) {\n  Logger.getLogger().error({\n    message: \"error while trying to do XXX\",\n    error: error,\n  });\n}\n```\n\n## Logging locations\n\nThe logger can write to various locations. These are all active by default.\n\n### Output channel\n\nEvery logging message of the levels info, warn and error are logged to the output channel.\n\nIf you want to open the output channel of the logs, you can use `logger.showOutputChannel`.\n\nThis can be used, if you have many information logs that were written during a command execution and at the end you have an error, which the user should be able to inspect.\n\n```typescript\nimport { Logger } from \"@aditosoftware/vscode-logging\";\n\nconst logger: Logger = Logger.getLogger();\n\n// a log of information that was logged to info (and not notify the user)\n\nlogger.warn({ message: \"execution of the command was not successful\", notifyUser: true });\nlogger.showOutputChannel();\n```\n\n### Console\n\nIf the variable `process.env.NODE_ENV` is not set to `production`, then any message logged to the files will be also logged to the console .\n\n### The log files\n\nAfter installing the extension, you can execute the command `workbench.action.openExtensionLogsFolder` to open the log folder for all extensions. Navigate in the folder of your extension.\nThe folders above your extensions folder and the deletion of old log folders are handled by VS Code.\n\nInside of this folder are two files: `error.log` and `\u003cName\u003e.log`.\n\n#### normal log file (`\u003cName\u003e.log`)\n\nThis file's name is dependent on the given name during the initialization of the logger.\n\nThis file is the main log file. It has all logs from all levels (debug, info, warn and error).\n\n#### error log file (`error.log`)\n\nThis fil only logs messages from the error level.\n\nAdditionally, it logs uncaught exceptions and uncaught rejections. Therefore, this log file should be used, if you are trying to find any errors and assume that there might be any uncaught errors.\n\n## Contribution Notes\n\nThe underlying logging framework is [winston](https://github.com/winstonjs/winston), with [winston-transport](https://github.com/winstonjs/winston-transport) used for additional transport methods.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faditosoftware%2Fvscode-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faditosoftware%2Fvscode-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faditosoftware%2Fvscode-logging/lists"}