|
import logging |
|
|
|
|
|
def setup_logger(name: str): |
|
logger = logging.getLogger(name) |
|
logger.setLevel(logging.DEBUG) |
|
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
|
|
|
|
|
file_handler = logging.FileHandler('mylog.log') |
|
file_handler.setLevel(logging.DEBUG) |
|
file_handler.setFormatter(formatter) |
|
logger.addHandler(file_handler) |
|
|
|
|
|
stream_handler = logging.StreamHandler() |
|
stream_handler.setLevel(logging.DEBUG) |
|
stream_handler.setFormatter(formatter) |
|
logger.addHandler(stream_handler) |
|
|
|
return logger |
|
|