-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Quality-of-Life 0: Logging (log-to-file, color in cli, formatting, other minor changes) #148
base: rewrite
Are you sure you want to change the base?
Conversation
Failed to account for all cases of extracted FS (hard crashes); working on it but as of now this is no longer ready. |
Thanks for the PR! I'll take a better look at the changes over the course of the next week. For the time being, just making the minimum changes needed to resolve the current merge conflicts should be alright. If any additional changes are needed, I'll just submit a review.
Static analysis tools should tell you about it, and it's usually not that hard to fix. But as I said before, I'll take a better look at the changes at a later time.
Personally, I would stick to the timestamp format used by nxdumptool logfile entries, which encloses the timestamp itself between brackets followed by the uppercase log level name, also enclosed between brackets:
I generally avoid using tab characters ( That being said, I'd probably use list comprehension for that part of the code: def format_message(self, record: logging.LogRecord) -> str:
content = self.format(record)
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
prepend = f'[{timestamp}] [{record.levelname}] '
return '\n'.join([(prepend + part) for part in content.split('\n') if part.strip()]) This essentially generates a log entry with a format that mimics nxdumptool's logfile. |
Yeah!
Yeah just glancing, looks like you turned on all the previously commented-out asserts, some changes in variable declarations, maybe some other things, not too bad
Aye aye cap'n.
Ah! Yes I remember you mentioned that it also logged, somehow did not occur to me to look at how that worked...
Noted, noted. Don't have any particular thoughts about bracketing the timestamp but the extra five characters of precision for the second seems like a bit much for most users--maybe this can continue to be truncated, except e.g. in verbose/debug mode? As for the tabs, I think GUI mode especially benefits from their use--I wouldn't characterize it as 'extremely necessary' by any means but the whitespace does wonders for readability, I find. That said, try it, etc.
This is so clean!!!! Otherwise I fixed the issue with raw HFS dumps and will at least get that out now |
I've changed the way transfer logging works in the 'general case' (not extractedFS or NSP) and also attempted to reconcile with upstream, but upstream changed since last I looked so I'll have to do that again. There's also one assert, |
Also: I am realizing that match/case is a Python 3.10+ feature. This will put nxdt out of reach of people with older systems, and the fact that you're checking for Vista and 7 (which only got official support up to 3.9 iirc) seems to suggest to me that this matters to you. If so I'll have to redo...a lot of things, I suppose |
While it now reports no conflicts, do not attempt to run yet. While some changes were of no consequence most need to now be reapplied. |
Added changes back without issue. |
After further testing, the approach taken of making the Windows path change as early instead of as late as possible has the consequence of every subsequent path set with g_outputDir as an input being mangled by os.path.abspath into a path that has all forward-slashes, including in the magic Windows prefix, when run in the MSYS2 environment CLI in Windows. I have reverted the behavior back and am testing again now. (I have also dispensed with removal of the Windows prefix when printing in verbose/debug mode as well, since that's precisely when we'd want to have that kind of information.) |
After further testing it appears that, longfile name syntax or not, MSYS2 or not, Windows appears to have the same 255 character/byte limit as other filesystems/operating systems do for the length of any individual file or folder in a given path. I didn't see official documentation of such a limitation but it's clear that it's there. While severely unlikely, sanitizing the user-entered path when entered from CLI would seem like a good idea for all systems; will try to get on this soon |
This PR does a few things on the server side, not to the core functionality at all but mainly consists of what I think are enhancements to the logging; my hope is you agree. I tried not to change the look of the UI and nor did I refactor any code out. I also tried to adhere to the existing naming conventions of variables and functions--point is I'm not trying to step on your toes, but think this might be nice.
Anyway, here's what this does:
Other minor changes:
-The bottom padding of elements at the bottom of the GUI are now tied to the font size; this is slightly cleaner-looking.
-The choose-directory prompt, instead of being seeded with the same root directory each time, will start from the last directory that was successfully submitted to it since the beginning of the program. If that directory was moved or deleted, then it will revert back to the default behavior.
-Refactored my earlier path-fixing code on Windows, removed it from one spot entirely (it was redundant, and so, prepended the magic string twice) and added references. Also, the paths aren't '32-bit' as I wrote earlier, but rather ~32,767 2-byte characters long.
I will also add logs and screenshots momentarily.
Limitations and possible pitfalls:
Otherwise, my preference is, uh, not to maintain and sync a fork for the sake of these cosmetic changes, so if there is something unacceptable here (or hell, even if it's all trash), please let me know, and maybe I could make it right. Otherwise, thanks again for your time and your support of this project!