astrodbtoolkit / astrodb_utils

https://astrodb-scripts.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
0 stars 4 forks source link

Setup logging #54

Open kelle opened 2 months ago

kelle commented 2 months ago

right now, logging is kinda implemented, but not necessarily formatted well. Someone could dig into that and make a logging setup which could be used by other ingest scripts.

@exu-112 made this start:


logger = logging.getLogger(__name__)

# Logger setup
# This will stream all logger messages to the standard output and
# apply formatting for that
logger.propagate = False  # prevents duplicated logging messages
LOGFORMAT = logging.Formatter(
    "%(asctime)s %(levelname)s: %(message)s", datefmt="%m/%d/%Y %I:%M:%S%p"
)
ch = logging.StreamHandler(stream=sys.stdout)
ch.setFormatter(LOGFORMAT)
# To prevent duplicate handlers, only add if they haven't been set previously
if len(logger.handlers) == 0:
    logger.addHandler(ch)
logger.setLevel(logging.INFO)
kelle commented 1 month ago

I also just generally don't understand how logging works. I don't understand how to pass the setup around to other modules.