-
Notifications
You must be signed in to change notification settings - Fork 5
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
Proper logging #232
Comments
Hi, I'm not sure whether it's exactly the same issue, but we're going to work on a similar problem. Here we'll write down all our actions and responsibilities so that it's easier to track our progress. The task :
Responsibilities : Scripts :
Pipelines :
15/06/2023 - start of work on this issue |
I've seen a lot of similar cases, so I want to add some information how to handle them here. Let's say, we have the following code : proc = subprocess.Popen(args, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) #on lance la commande définie dans args, on dit qu'on n'a pas besoin de stdout, et s'il y a quelque erreur, on print cela To turn the print into a logger, we simply need to refer to the variable, without any extra parameters : Another thing which is worth explaining is the loggin insert-variables. When it comes to choosing between %s and %d in logging messages, it depends on the type of the variable you are inserting and the desired behavior: In general, if we are confident that the variable we are inserting is always going to be an integer, we can use %d for clarity (as I already started doing). However, if the variable can be of different types, or if we prefer a more flexible approach, we can use %s to allow for automatic string conversion. It's worth noting that in newer versions of Python (3.6 and above), there is an alternative method of string formatting using f-strings, which provide a more concise and readable syntax. For example, instead of %s, we can use {} as a placeholder, and directly insert the variable using f-strings, like logging.warning('{}'.format(warning_name)) or logging.warning(f'{warning_name}'). |
Is your feature request related to a problem? Please describe.
The use of printf everywhere getting messy and unclear
Describe the solution you'd like
https://stackoverflow.com/questions/42388844/where-to-configure-logging
The text was updated successfully, but these errors were encountered: