Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/toolong/log_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from datetime import datetime
from importlib_metadata import entry_points
import os
import mmap
import mimetypes
Expand Down Expand Up @@ -36,6 +37,10 @@ def __init__(self, path: str) -> None:
self.timestamp_scanner = TimestampScanner()
self.format_parser = FormatParser()
self._lock = Lock()
# Plugin entry point for other packages to overwrite the format parsers
for entry_point in entry_points(group="toolong.application.format_parsers"):
format_parser_plugin = entry_point.load()
self.format_parser = format_parser_plugin(self)

def __rich_repr__(self) -> rich.repr.Result:
yield self.name
Expand Down