Use more unique yet short paths for logging #2642
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now ZeroNet logs tend to be literally useless for debugging because most of the paths are incomprehensible. I propose replacing the path shortening algorithm with a more subtle one. Here are the major changes:
src/Ui/__init__.py
, should they appear in a traceback, are now encoded asUi/__init__.py
(was:__init__.py
).plugins/Chart/ChartDb.py
are now encoded asChartDb.py
(was:Chart/ChartDb.py
). In general, paths such asA/AB/ABC/X.py
are now encoded asABC/X.py
to remove unnecessary prefixes.<frozen importlib._bootstrap>
, which may appear in a traceback due to import errors, are now skipped (was:<frozen importlib._bootstrap>
)..../src/
), paths outside ZeroNet root, should they appear in a traceback, are now anonymized:/root/ZeroNet/src/main.py
is now encoded as?/src/main.py
(was:main.py
)..../site-packages/gevent/__init__.py
is now encoded as<gevent>/__init__.py
(was:__init__.py
)./usr/lib/python3.8/os.py
is now encoded as<os>
(was:os.py
).src/gevent/event.py
are correctly parsed as<gevent>/event.py
(was:event.py
).I've also added some tests.