utils.py

Mon, 22 Jan 2018 02:37:46 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 22 Jan 2018 02:37:46 +0000
changeset 47
305de2297fde
parent 40
cfbeeec8cb82
permissions
-rw-r--r--

README configuration file location update

40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 #
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2 # Utility functions for Borgend
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
3 #
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
4
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
5 def log_exception(logger, err, detail=None):
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
6 err_type=err.__class__.__name__
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
7 if detail:
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
8 logger.critical('%s:%s "%s"', str(detail), err_type, str(err))
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
9 else:
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
10 logger.critical('%s "%s"', err_type, str(err))

mercurial