naturalis / barcode-constrained-phylogeny

Pipeline for building topologically-constrained phylogenies from DNA barcode data
https://naturalis.github.io/barcode-constrained-phylogeny/
Apache License 2.0
2 stars 3 forks source link

Add date/time stamp to log messages #80

Closed rvosa closed 6 months ago

rvosa commented 7 months ago
import logging

# Create a logger
logger = logging.getLogger(__name__)

# Set the log level
logger.setLevel(logging.DEBUG)

# Create a console handler
handler = logging.StreamHandler()

# Define the format for the log messages,
# including the date and time stamp
log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

# Set the date format
date_format = '%Y-%m-%d %H:%M:%S'

# Create a formatter using the specified format and date format
formatter = logging.Formatter(log_format, datefmt=date_format)

# Set the formatter for the handler
handler.setFormatter(formatter)

# Add the handler to the logger
logger.addHandler(handler)

# Example log message
logger.debug('This is a debug message.')
rvosa commented 7 months ago

Put log_format and date_format in config.yml

rvosa commented 7 months ago

util package for doing this is added as per commit https://github.com/naturalis/barcode-constrained-phylogeny/commit/8725d51ba7dd329361b429e1b1ec39ae68601a81

rvosa commented 7 months ago

added formatted logging to four rules as per commit https://github.com/naturalis/barcode-constrained-phylogeny/commit/469d75e00e8d6ccbd179d39657f072a33a7dbc60