utils.py

Sun, 21 Jan 2018 22:43:57 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 21 Jan 2018 22:43:57 +0000
changeset 43
8f3ac19f11b6
parent 40
cfbeeec8cb82
permissions
-rw-r--r--

Use platform package to detect whether to:
* rumps vs. xdg for configuration file location, and
* try to display a tray icon

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