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

Suggestion: Create this logger outside of the method #72

Open
mpvanderschelling opened this issue Dec 6, 2023 · 0 comments
Open

Suggestion: Create this logger outside of the method #72

mpvanderschelling opened this issue Dec 6, 2023 · 0 comments

Comments

@mpvanderschelling
Copy link

Problem

Create this logger outside of the method, this makes the code more concise and easier to read.

Solution

Create the logger in a separate module and import it into the module where it is used.

Assignees:
Labels:

if self.print_log:
file_handler = logging.FileHandler("microstructure.log")
file_handler.setLevel(logging.INFO)
# Create a logging format
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
file_handler.setFormatter(formatter)
# Add the handlers to the logger
self.logger.addHandler(file_handler)

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

No branches or pull requests

1 participant