diff options
Diffstat (limited to 'catapult/telemetry/telemetry/internal/util/atexit_with_log.py')
-rw-r--r-- | catapult/telemetry/telemetry/internal/util/atexit_with_log.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/catapult/telemetry/telemetry/internal/util/atexit_with_log.py b/catapult/telemetry/telemetry/internal/util/atexit_with_log.py new file mode 100644 index 00000000..6dd79670 --- /dev/null +++ b/catapult/telemetry/telemetry/internal/util/atexit_with_log.py @@ -0,0 +1,16 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import atexit +import logging + +def _WrapFunction(function): + def _wrapped_function(*args, **kwargs): + logging.debug('Try running %s', repr(function)) + function(*args, **kwargs) + logging.debug('Did run %s', repr(function)) + return _wrapped_function + +def Register(function, *args, **kwargs): + atexit.register(_WrapFunction(function), *args, **kwargs) |