busimus / cutelog

GUI for logging
MIT License
479 stars 45 forks source link

fix Load records from json log file #38

Closed SaeidJavadi closed 1 year ago

SaeidJavadi commented 1 year ago

In most of the time or always the logs are saved as json line to line in the file As:

{"asctime": "2023-01-31", "name": "__main__", "levelname": "DEBUG", "filename": "main.py", "lineno": 241}
{"asctime": "2023-01-31", "name": "__main__", "levelname": "DEBUG", "filename": "main.py", "lineno": 51}
{"asctime": "2023-01-31", "name": "__main__", "levelname": "DEBUG", "filename": "main.py", "lineno": 1073}

And when loading it in the app we have to manually turn it into a list of JSON As:

[ {"asctime": "2023-01-31", "name": "__main__", "levelname": "DEBUG", "filename": "main.py", "lineno": 241},
{"asctime": "2023-01-31", "name": "__main__", "levelname": "DEBUG", "filename": "main.py", "lineno": 51},
{"asctime": "2023-01-31", "name": "__main__", "levelname": "DEBUG", "filename": "main.py", "lineno": 1073} ]

For this reason, I added these to the app to automatically change and load the log file (by creating a Temp file) The original file does not change the log and only creates a new modified file and erases it after Load Because the next logs are added to the same log file, so the original file should not be changed