-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin entry points #47
base: main
Are you sure you want to change the base?
Conversation
Allow other packages to customise both the formatters and the FormatParser class by using custom entrypoints Signed-off-by: Phil Ewels <[email protected]>
I'm nearly at the point now where I'm happy / done with this functionality now. However, there is one sticking point that I'm struggling with. The log files I'm parsing have I tried adding a status variable in the I wondered about doing a pre-run through the file somehow to add markers to the start of each line, which I could then use in the highlighting. But again Toolong is too smart and doesn't fetch the entire file into memory. The best I've got is to somehow hijack the reading, copy to a tmpfile and edit in place, then continue with regular loading. But that feels very hacky, and would break file tailing. So I'm a bit stuck and out of ideas. @willmcgugan any suggestions? Or should I give up on this front? 😬 😅 |
My only concern is that I think this approach may not work well with some installation methods. If you install with pipx or brew, then you could only add entry points if you install them in to the same virtual environment. It is a good idea to allow third-party formatters. But maybe this should be a config file that references a plugin. Ideally the plugin would be something declarative, like a regex styles. Haven't considered follow on lines. I think that would require an extension to the format parser system. |
Right, good point about the installation methods 👍🏻 I've actually been a little cheeky in this instance and added a new I agree that a config based / declarative plugin system would be nicer for most users. I'm not really sure where I'd start with that though. |
Allow other packages to customise both the formatters and the FormatParser class by using custom entrypoints.
Proposing as an alternative to #45 - these entrypoints allow me to put that custom highlighter code in another Python package. It can be maintained in a separate release cycle there, and means that it doesn't pollute the main toolong code base for all other users.