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

logfile for debug-mode #105

Open
b166er opened this issue Jul 24, 2024 · 2 comments
Open

logfile for debug-mode #105

b166er opened this issue Jul 24, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@b166er
Copy link

b166er commented Jul 24, 2024

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
for better error analysis, it would be great if the output from the console could be saved to a file at the same time in debug mode.

Describe alternatives you've considered
it only requires a one-liner in the code shown below

diff --git a/pytr/utils.py b/pytr/utils.py
index c235a42..5f9e21d 100644
--- a/pytr/utils.py
+++ b/pytr/utils.py
@@ -32,6 +32,8 @@ def get_logger(name=__name__, verbosity=None):
     logger.propagate = False
 
     if log_level == 'debug':
+        # (over)write logs to file
+        logging.basicConfig(filename='debug.log', filemode='w+', level=logging.DEBUG)
+        # need logs from other classes
+        logger.propagate = True
         fmt = '%(asctime)s %(name)-9s %(levelname)-8s %(message)s'
         datefmt = '%Y-%m-%d %H:%M:%S%z'
     else:

thanks

@b166er b166er added the enhancement New feature or request label Jul 24, 2024
@Katzmann1983
Copy link
Collaborator

Especially the logger.propagate seems mostly interesting when trying to debug connection issues. Not sure, that this is a generally advisable setting. Regarding the overall idea to log to a file, why not use the typical command line approach of redirecting the output?

@b166er
Copy link
Author

b166er commented Aug 25, 2024

a debug option would be nice if the application can write everything to a log file for me. then I don't have to worry about output forwarding myself. Otherwise, you can of course forward the output yourself, that's true. That would be a home-made solution without having to modify anything in the application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants