Commit 1e398d53 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

default logger does not write to file

parent ab27dee5
...@@ -10,9 +10,10 @@ Modified-History: ...@@ -10,9 +10,10 @@ Modified-History:
2022-10-07, Bo Zhang, added Numpydoc docstring 2022-10-07, Bo Zhang, added Numpydoc docstring
""" """
import logging import logging
from typing import Optional
def get_logger(name: str = "CSST pipeline", filename: str = "test.log"): def get_logger(name: str = "CSST pipeline", filename: Optional[str] = None):
""" """
Get a logger for CSST pipelines. Get a logger for CSST pipelines.
...@@ -59,7 +60,7 @@ def get_logger(name: str = "CSST pipeline", filename: str = "test.log"): ...@@ -59,7 +60,7 @@ def get_logger(name: str = "CSST pipeline", filename: str = "test.log"):
logger.addHandler(stream_handler) logger.addHandler(stream_handler)
# file handler # file handler
if filename != "": if filename is not None:
file_handler = logging.FileHandler(filename=filename, encoding="utf-8") file_handler = logging.FileHandler(filename=filename, encoding="utf-8")
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
file_handler.setLevel(logging.INFO) file_handler.setLevel(logging.INFO)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment