summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-05-02 22:16:52 -0400
committerPeter LaFosse <peter@vector35.com>2017-05-02 22:16:52 -0400
commit597a190065ed23553c8351905803b6b5699c18cd (patch)
tree186386f27c3dbd936dd99dd9b2ab10db9a190668 /python
parent62a96d238dcfe93542f495c0a303baf2d4b3e046 (diff)
add method to query log output state
Diffstat (limited to 'python')
-rw-r--r--python/examples/bin_info.py1
-rw-r--r--python/log.py13
-rw-r--r--python/scriptingprovider.py11
3 files changed, 14 insertions, 11 deletions
diff --git a/python/examples/bin_info.py b/python/examples/bin_info.py
index 4c4ab8fd..495fb5b5 100644
--- a/python/examples/bin_info.py
+++ b/python/examples/bin_info.py
@@ -38,7 +38,6 @@ def get_bininfo(bv):
sys.exit(1)
bv = BinaryViewType.get_view_of_file(filename)
- log.redirect_output_to_log()
log.log_to_stdout(True)
contents = "## %s ##\n" % bv.file.filename
diff --git a/python/log.py b/python/log.py
index f09b94a1..850772f1 100644
--- a/python/log.py
+++ b/python/log.py
@@ -23,6 +23,19 @@
import _binaryninjacore as core
+_output_to_log = False
+
+
+def redirect_output_to_log():
+ global _output_to_log
+ _output_to_log = True
+
+
+def is_output_redirected_to_log():
+ global _output_to_log
+ return _output_to_log
+
+
def log(level, text):
"""
``log`` writes messages to the log console for the given log level.
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py
index 1fe5d1e3..859f262e 100644
--- a/python/scriptingprovider.py
+++ b/python/scriptingprovider.py
@@ -35,13 +35,6 @@ import basicblock
import startup
import log
-_output_to_log = False
-
-
-def redirect_output_to_log():
- global _output_to_log
- _output_to_log = True
-
class _ThreadActionContext(object):
_actions = []
@@ -384,14 +377,12 @@ class _PythonScriptingInstanceOutput(object):
return self.write('\n'.join(lines))
def write(self, data):
- global _output_to_log
-
interpreter = None
if "value" in dir(PythonScriptingInstance._interpreter):
interpreter = PythonScriptingInstance._interpreter.value
if interpreter is None:
- if _output_to_log:
+ if log.is_output_redirected_to_log():
self.buffer += data
while True:
i = self.buffer.find('\n')