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
Request ability to interpret new line characters in the right panel #49
Comments
Example log file Wed Apr 24 10:22:22 2024 \n+-----------------------------------------------------------------------------------------+\n| NVIDIA-SMI 550.40.07 Driver Version: 551.52 CUDA Version: 12.4 |\n|-----------------------------------------+------------------------+----------------------+\n| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n| | | MIG M. |\n|=========================================+========================+======================|\n| 0 NVIDIA T1200 Laptop GPU On | 00000000:01:00.0 On | N/A |\n| N/A 51C P8 8W / 80W | 835MiB / 4096MiB | 6% Default |\n| | | N/A |\n+-----------------------------------------+------------------------+----------------------+\n \n+-----------------------------------------------------------------------------------------+\n| Processes: |\n| GPU GI CI PID Type Process name GPU Memory |\n| ID ID Usage |\n|=========================================================================================|\n| 0 N/A N/A 22 G /Xwayland N/A |\n+-----------------------------------------------------------------------------------------+ Possible fix, add the following line before the yield there line_panel.py#L45 : self.text._text[0] = re.sub("\\\\n", "\n", self.text._text[0]) It does the job but I feel like this is not the right place for it. Maybe textualize should provide an adapted Text type for this. @willmcgugan What is your advice on this ? |
Ah, so these are escaped newlines. Is it common for logs to do that? Seems like a reasonable thing to do. I wonder if it should be an option, in case "\n" appears in a log file that wasn't intended to be a newline. |
I don't know if it's common but I try to avoid writing multiline logs to never loose track of the beginning of the line (log level, datetime, etc). And also that's where toolong comes very handy. I agree to make it optional. $ tl --help
Usage: tl [OPTIONS] FILE1 FILE2
View / tail / search log files.
Options:
--version Show the version and exit.
-m, --merge Merge files.
-n, --new-lines Unescape newline characters in the line panel
-o, --output-merge PATH Path to save merged file (requires -m).
--help |
Added this to 1.5.0. It will automatically unescape newlines. If anyone complains, I might put it behind a switch |
Thank you for developing toolong; it has proven to be incredibly useful.
I've noticed that my logs sometimes contain numerous newline characters (
\n
), particularly evident when outputting results from commands likenvidia-smi
. When I click on a logline, the right panel opens, which is a convenient feature for viewing the entirety of the log with a vertical scrollbar. However, since newline characters are not interpreted, the content can become difficult to read depending on its structure.Could we consider adding the interpretation of newline characters ? Maybe optionally? This would enhance the readability of the logs for users dealing with similar formatting issues.
I am keen to contribute if necessary
The text was updated successfully, but these errors were encountered: