Python logging done/fail messages -


when using python logging library, standard approach write message this:

logging.info("all right") 

but necessary show result status of (long) task (after while after output of main part of message). example:

some long computing...    [done] 

or

some long computing...    [fail] 

how can solve problem?

total:

ok. possible, in next line. output success message in same line must use other tool (probably, custom), not logging python library.

it sounds might out.

import logging  logging.basicconfig(format = "%(asctime)s - %(levelname)s - %(message)s",                      level = logging.debug)  logging.info("long task starting") try:     startlongtaskfunction()     logging.info("long task finished") except:     logging.exception("long task failed") 

note logging.exception() different logging.error(). after log entry added logging.exception(), entire python error message included well.

if want log critical events in startlongtaskfunction, can insert log entries inside function well. if import function separate module, can still reference same log file.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -