Open LOHMgit opened 2 years ago
def get_logger(): module_name = file.split('/')[-1].split('.')[0]
logger = logging.getLogger(module_name)
logger.setLevel(logging.DEBUG)
logger.handlers = []
#set up a stream handler
s_handler = logging.StreamHandler()
s_handler.setLevel(logging.DEBUG)
log_format = logging.Formatter(fmt='%(asctime)s | %(levelname)s | %(message)s | %(name)s',
datefmt='%Y-%m-%d %H:%M:%S')
s_handler.setFormatter(log_format)
logger.addHandler(s_handler)
return logger
Here is how I was handling it before...
@LOHMgit I think we're mostly using print statements to modal now. Is there any advantage to doing this kind of logging?
@woodwardmw Does SIL have any centralized logging service that they use?
We need to log to stdout because this is how Pachyderm will be able to track the logs from the container. So, I don't think that we need to set file related things. In terms of logging more generally, maybe we want to do something like this, but at a higher level for the API (such that all the scripts and API itself can import this). However, let's push that to a new PR. For now, I think something like the following would suffice:
import logging logging.warning('Watch out!') # will print a message to the console logging.info('I told you so') # will not print anything