{"id":13475935,"url":"https://github.com/sindresorhus/electron-timber","last_synced_at":"2025-04-13T11:48:20.098Z","repository":{"id":55414902,"uuid":"118626461","full_name":"sindresorhus/electron-timber","owner":"sindresorhus","description":"Pretty logger for Electron apps","archived":false,"fork":false,"pushed_at":"2024-05-01T09:13:24.000Z","size":79,"stargazers_count":408,"open_issues_count":8,"forks_count":13,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-04T05:08:27.032Z","etag":null,"topics":["electron","electron-module","logger","logging","logging-library","nodejs","npm-package"],"latest_commit_sha":null,"homepage":null,"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/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"},"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":"2018-01-23T15:07:34.000Z","updated_at":"2025-03-26T01:52:19.000Z","dependencies_parsed_at":"2024-11-06T00:47:42.643Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/electron-timber","commit_stats":{"total_commits":25,"total_committers":4,"mean_commits":6.25,"dds":"0.31999999999999995","last_synced_commit":"5cbf50d611387b130829d14781e1268844dd6047"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-timber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-timber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-timber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-timber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/electron-timber/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112841,"owners_count":21049735,"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":["electron","electron-module","logger","logging","logging-library","nodejs","npm-package"],"created_at":"2024-07-31T16:01:24.856Z","updated_at":"2025-04-13T11:48:20.079Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# electron-timber\n\n\u003e Pretty logger for Electron apps\n\n\u003cimg src=\"screenshot.png\" width=\"1100\"\u003e\n\nBy default, logs from the renderer process don't show up in the terminal. Now they do.\n\nYou can use this module directly in both the main and renderer process.\n\n## Install\n\n```sh\nnpm install electron-timber\n```\n\n*Requires Electron 30 or later.*\n\n## Usage\n\nMain process:\n\n```js\nimport {app, BrowserWindow} from 'electron';\nimport logger from 'electron-timber';\n\nlet mainWindow;\n\n(async () =\u003e {\n\tawait app.whenReady();\n\n\tmainWindow = new BrowserWindow();\n\tawait mainWindow.loadURL(…);\n\n\tlogger.log('Main log');\n\tlogger.error('Main error');\n\n\tconst customLogger = logger.create({name: 'custom'});\n\tcustomLogger.log('Custom log');\n})();\n```\n\nRenderer process:\n\n```js\nimport logger from 'electron-timber';\n\nlogger.log('Renderer log');\nlogger.error('Renderer error');\n```\n\n## API\n\n## logger\n\nLogging will be prefixed with either `main` or `renderer` depending on where it comes from.\n\nLogs from the renderer process only show up if you have required `electron-timber` in the main process.\n\nThe methods are bound to the class instance, so you can do: `const log = logger.log; log('Foo');`.\n\n### log(…values)\n\nLike `console.log`.\n\n### warn(…values)\n\nLike `console.warn`.\n\n### error(…values)\n\nLike `console.error`.\n\n### time(label)\n\nLike `console.time`.\n\n### timeEnd(label)\n\nLike `console.timeEnd`.\n\n### streamLog(stream)\n\nLog each line in a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams). For example, `child_process.spawn(…).stdout`.\n\n### streamWarn(stream)\n\nSame as `streamLog`, but logs using `console.warn` instead.\n\n### streamError(stream)\n\nSame as `streamLog`, but logs using `console.error` instead.\n\n### create(options?)\n\nCreate a custom logger instance.\n\nYou should initialize this on module load so prefix padding is consistent with the other loggers.\n\n#### options\n\nType: `object`\n\n##### name\n\nType: `string`\n\nName of the logger. Used to prefix the log output. Don't use `main` or `renderer`.\n\n##### ignore\n\nType `RegExp`\n\nIgnore lines matching the given regex.\n\n##### logLevel\n\nType: `string`\n\nCan be `info` (log everything), `warn` (log warnings and errors), or `error` (log errors only). Defaults to `info` during development and `warn` in production.\n\n### getDefaults()\n\nGets the default options (across `main` and `renderer` processes).\n\n### setDefaults(options?) \u003csup\u003e\u003csmall\u003e*Main process only*\u003c/small\u003e\u003c/sup\u003e\n\nSets the default options (across `main` and `renderer` processes).\n\n#### options\n\nType: `object`\n\nSame as the `options` for `create()`.\n\n## Toggle loggers\n\nYou can show the output of only a subset of the loggers using the environment variable `TIMBER_LOGGERS`. Here we show the output of the default `renderer` logger and a custom `unicorn` logger, but not the default `main` logger:\n\n```sh\nTIMBER_LOGGERS=renderer,unicorn electron .\n```\n\n## Related\n\n- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps and modules\n- [electron-reloader](https://github.com/sindresorhus/electron-reloader) - Simple auto-reloading for Electron apps during development\n- [electron-serve](https://github.com/sindresorhus/electron-serve) - Static file serving for Electron apps\n- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app\n- [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app\n- [electron-dl](https://github.com/sindresorhus/electron-dl) - Simplified file downloads for your Electron app\n- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Library","Tools"],"sub_categories":["Logging","For Electron"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Felectron-timber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Felectron-timber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Felectron-timber/lists"}