kopia lustrzana https://github.com/OpenDroneMap/ODM
Add logging module
rodzic
fea6bcccbe
commit
b807b07920
|
@ -1,3 +1,5 @@
|
|||
import logging
|
||||
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
OKGREEN = '\033[92m'
|
||||
|
@ -5,18 +7,29 @@ WARNING = '\033[93m'
|
|||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
|
||||
# TODO add file handling
|
||||
|
||||
logging.addLevelName(logging.INFO, '%s[%s]' % (OKBLUE, logging.getLevelName(logging.INFO)))
|
||||
logging.addLevelName(logging.WARNING, '%s[%s]' % (WARNING, logging.getLevelName(logging.WARNING)))
|
||||
logging.addLevelName(logging.ERROR, '%s[%s]' % (FAIL, logging.getLevelName(logging.ERROR)))
|
||||
logging.addLevelName(logging.DEBUG, '%s[%s]' % (OKGREEN, logging.getLevelName(logging.DEBUG)))
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(levelname)-14s %(message)s' + ENDC)
|
||||
|
||||
|
||||
def ODM_INFO(str):
|
||||
print OKBLUE + '[INFO] ' + str + ENDC
|
||||
logging.info(str)
|
||||
|
||||
|
||||
def ODM_WARNING(str):
|
||||
print WARNING + '[WARNING] ' + str + ENDC
|
||||
logging.warning(str)
|
||||
|
||||
|
||||
def ODM_ERROR(str):
|
||||
print FAIL + '[ERROR] ' + str + ENDC
|
||||
logging.error(str)
|
||||
|
||||
|
||||
def ODM_DEBUG(str):
|
||||
print OKGREEN + '[DEBUG] ' + str + ENDC
|
||||
logging.debug(str)
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@ def run(cmd):
|
|||
returnCode = os.system(cmd)
|
||||
|
||||
if (returnCode != 0):
|
||||
# TODO(edgar): add as log.ODM_ERROR
|
||||
sys.exit("\nquitting cause: \n\t" + cmd + "\nreturned with code " +
|
||||
log.ODM_ERROR("quitting cause: \n\t" + cmd + "\nreturned with code " +
|
||||
str(returnCode) + ".\n")
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue