I'm getting an error: I've only used it as recommended in README. My version is & is . I've bootstrapped the project from https://electron-vite.org/ if it helps. I'm also using https://www.npmjs.com/package/@electron-toolkit/typed-ipc like so - https://github.com/deadcoder0904/electron-typed-ipc-poc (the latest commit is broken if you wanna repro but 1 previous commit works) Any way to fix this?
I've tried my best to keep the code as short and concise as possible, and not adding new external deps (the only exception is the package , maintained by @sindresorhus), but this PR has become something really big :sweat_smile: Any insights/help will be greatly appreciated. Still missing some features that I would like to include. New options [x] (, , or ; defaults to ): the logger that will collect all the logger messages. All messages are logged on their original logger apart from the collector. This implements #15 : : removes any collector and each side (main/renderer) collects its own messages. : all logged messages are collected on (default behavior until now). : all logged messages are collected on the first created browserWindow. : all logged messages are collected on the browserWindow with ID after it is created (all messages logged prior to its creation are only logged on their respective loggers). [x] ( or ; defaults to ): if electron app is using the devTools dark theme, otherwise. When prettifying the logged message, all colors are check at renderer side when internally cached to improve the contrast, so the messages are legible. [x] (, or a level priority (0=error, 1=warn, 2=everything else); defaults to ): allows muting the messages printed by Electron. Combining this option with , user can mute messages with a very fine-grained control. This closes #13 . [x] (, or ; defaults to ): the logged text can be colorized on both sides (main/renderer). If a transport does not support this feature, defaults to . Possible values: : strips all colors. : colorizes only the context part (). : colorizes the context and all the arguments passed to the logging method. [x] (any non-empty string; defaults to ): the separator used to separate the context and the message. [x] (, or ; defaults to ): messages can be prepended with a (ISO formatted or only time) timestamp on demand, which defaults to , and may have as possible values , or . This feature is only available for main logger because user can manually activate this on renderer devTools under . [x] (; defaults to ): the transports to set up for all loggers. New features [x] User can now from renderer process(es) too. [x] Loggers with the same name (no matter on which side, main/renderer) share the same options (which may be overriden by instance-specific options at creation time), inheriting from existent instances with the same logger name. [x] New mechanism to load transports on demand, which helps isolating stuff and prepare for #7 (add ability to also log to disk). Right now, if no transport is provided, the is always used as default (which is the unique currently available). [x] The default log levels are now (0), (1), (2) (with as alias), (3), (4), (5). So it's backwards compatible and provides new methods for more fine-grained control. User can set its own log levels through the new public method . [x] Default logger is named , and if no provided when creating a custom logger, then tries to find out the caller package and extract its name from its file. If not found, it will throw an error. [x] Now all args are prettified on both side consoles (main/renderer). If any of the args is not a string, then it's printed as object on renderer console(s) to allow inspection or prettified on main (terminal) console to ease inspection. [x] Every logged message is now prepended with its context, wich is the logger name plus its side (and optionally the browserWindow ID on renderer side). Examples: , . This eases a lot debugging multi-window apps and distinguishing one logger from another after fixing #15 . [ ] TODO Handle (on both sides), prettify (on main process like pretty-exceptions) and collect (through option) uncatched exceptions. [ ] TODO Allow overriding defaults through command line parameters (like : ,...). Internals/refactor [x] stuff moved to its own class, extended by and . [x] All constants and literals moved into and imported where/when necessary. [x] The log level helper methods (, , , and so on) are created, optimized and binded dynamically now (these are inferred from the log levels, global defaults and other options). [ ] TODO Update . [ ] TODO Adapt (old) and write (new) tests. Fixes [x] Measures taken with / were always being logged previously. Now they are logged based on the logger (they default to be printed with / level). [x] Chromium devTools/extensions are loading the preload script, so they usually cause #13. [x] Relying on was missing some browserWindows because of its asynchronous behaviour. [x] The logger context was not being added to messages from streams. [x] The messages captured from browser (renderer) native console calls were not being stripped custom CSS (whenever present). [x] The context (and thus the logged messages) is correctly padded on renderer sides now. Closes [x] Closes #13 (filter out Electron junk logging). [x] Closes #15 (add option to show main process output in the renderer). [x] Closes #16 (separate main and renderer logic). Some screenshots of this PR in action Collector as with multiple browserWindows, hooking native console and prettifying : !timber - main console Collector as with multiple browserWindows, native console hooked, prettified and devTools with dark theme: !timber - renderer console
Repository: sindresorhus/electron-timber. Description: Pretty logger for Electron apps Stars: 423, Forks: 9. Primary language: JavaScript. License: MIT. Topics: electron, electron-module, logger, logging, logging-library, nodejs, npm-package. Open PRs: 0, open issues: 9. Last activity: 2y ago. Top contributors: sindresorhus, acheronfail, Richienb.