{"id":15711260,"url":"https://github.com/jeremyben/webpack-webextension-background-logger","last_synced_at":"2025-10-20T15:30:28.526Z","repository":{"id":93739653,"uuid":"166292592","full_name":"jeremyben/webpack-webextension-background-logger","owner":"jeremyben","description":"Centralize console logs in background page (web/chrome extensions)","archived":false,"fork":false,"pushed_at":"2020-05-30T20:09:21.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-12T03:06:04.213Z","etag":null,"topics":["chrome-extension","log-centralization","webpack"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/webpack-webextension-background-logger","language":"JavaScript","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/jeremyben.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":"2019-01-17T20:32:18.000Z","updated_at":"2020-05-30T20:09:23.000Z","dependencies_parsed_at":"2023-04-03T12:32:28.132Z","dependency_job_id":null,"html_url":"https://github.com/jeremyben/webpack-webextension-background-logger","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"bb279968f347fade7f3af6afb58e8c4d0fd03d18"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyben%2Fwebpack-webextension-background-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyben%2Fwebpack-webextension-background-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyben%2Fwebpack-webextension-background-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyben%2Fwebpack-webextension-background-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeremyben","download_url":"https://codeload.github.com/jeremyben/webpack-webextension-background-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237349665,"owners_count":19295599,"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":["chrome-extension","log-centralization","webpack"],"created_at":"2024-10-03T21:12:20.060Z","updated_at":"2025-10-20T15:30:23.183Z","avatar_url":"https://github.com/jeremyben.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web Extension Background Logger\n\n## What\n\n**Log centralization** for you Web/Chrome Extension.\nCompatible with every browser extension : **Chrome**, **Firefox**, **Safari**, **Edge**.\n\n## Why\n\nWhen you develop your Web Extension, you have to keep an eye on multiple consoles and logs from :\n\n- Background script.\n- Content script.\n- Popup page (either _page action_ or _browser action_).\n- Option page.\n\nThis webpack plugin allows you to centralize all logs in the background page console.\n\n## Get Started\n\nFirst, install Web Extension Background Logger :\n\n```bash\n# npm\nnpm i -D webpack-webextension-background-logger\n\n# yarn\nyarn add -D webpack-webextension-background-logger\n```\n\nAdd to your Webpack config :\n\n```js\nconst BackgroundLogger = require('webpack-webextension-background-logger')\n\nmodule.exports = {\n  // your webpack config\n  // ...\n\n  plugins: [new BackgroundLogger()],\n}\n```\n\nWeb Extension Background Logger will look for an entry named `background` by default, but you can customize this :\n\n```js\nnew BackgroundLogger({ backgroundEntry: 'main' })\n```\n\n## Usage\n\nNow, instead of using good old `console.log`, simply use `console.bg` :\n\n```js\nconsole.bg('loggy-log-log', foo)\n```\n\nThis will print your log in the background page console.\n\n#### Types for `console.bg`\n\nIf you use TypeScript, or type check your JavaScript (like this project does), you might want to tell the compiler that `console.bg` exists.\n\nTo do this, include in a declaration file (`typings.d.ts` for example) at the root of your project :\n\n```ts\n/// \u003creference types=\"webpack-webextension-background-logger/console\" /\u003e\n```\n\nOr you can add to your `tsonfig.json` :\n\n```json\n{\n  \"compilerOptions\": {\n    \"typeRoots\": [\"node_modules/@types\", \"node_modules/webpack-webextension-background-logger\"]\n  }\n}\n```\n\n### Production build\n\nFor production builds, you can opt out of background logger and revert to plain `console.log` statements :\n\n```js\nnew BackgroundLogger({ revertToLog: true })\n```\n\nThis will simply remove Background Logger from your build and rewrite every `console.bg` statement into `console.log` statement.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremyben%2Fwebpack-webextension-background-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeremyben%2Fwebpack-webextension-background-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremyben%2Fwebpack-webextension-background-logger/lists"}