From 4c806caeb93f5e9495e12eacad7a79b23bc27d29 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Thu, 5 Mar 2020 00:13:24 -0600 Subject: [PATCH] Draft: utils, add function to log calls --- src/Mod/Draft/draftutils/utils.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index bb747008e4..b13d3e3d87 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -38,7 +38,7 @@ from PySide import QtCore import FreeCAD import Draft_rc -from draftutils.messages import _msg +from draftutils.messages import _msg, _log from draftutils.translate import _tr App = FreeCAD @@ -1019,3 +1019,29 @@ def utf8_decode(text): return text.decode("utf-8") except AttributeError: return text + + +def print_header(name, description, debug=True): + """Print a line to the console when something is called, and log it. + + Parameters + ---------- + name: str + The name of the function or class that is being called. + This `name` will be logged in the log file, so if there are problems + the log file can be investigated for clues. + + description: str + Arbitrary text that will be printed to the console + when the function or class is called. + + debug: bool, optional + It defaults to `True`. + If it is `False` the `description` will not be printed + to the console. + On the other hand the `name` will always be logged. + """ + _log(name) + if debug: + _msg(16 * "-") + _msg(description)