diff options
| author | Brian Potchik <brian@vector35.com> | 2020-09-16 18:01:12 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2020-09-16 18:01:12 -0400 |
| commit | 0fa07f755371447b9d733c6f89bb93f1ece5e7e1 (patch) | |
| tree | 6b427ee88ecd2446adfd6ec77cc22dca64d6b2c9 /python/__init__.py | |
| parent | 766746a4c82730f266e2ddd0dcb84eb4a09d56ca (diff) | |
Add 'disable_default_log' method in the Python API.
Diffstat (limited to 'python/__init__.py')
| -rw-r--r-- | python/__init__.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/python/__init__.py b/python/__init__.py index f4a91250..352ecc42 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -157,15 +157,18 @@ class _DestructionCallbackHandler(object): Function._unregister(func) +_enable_default_log = True _plugin_init = False def _init_plugins(): + global _enable_default_log global _plugin_init if not _plugin_init: - result = core.BNInitCorePlugins() + # The first call to BNInitCorePlugins returns True for successful initialization and True in this context indicates headless operation. + is_headless = core.BNInitCorePlugins() min_level = Settings().get_string("python.log.minLevel") - if result and min_level in LogLevel.__members__ and not core_ui_enabled() and sys.stderr.isatty(): + if _enable_default_log and is_headless and min_level in LogLevel.__members__ and not core_ui_enabled() and sys.stderr.isatty(): log_to_stderr(LogLevel[min_level]) if not os.environ.get('BN_DISABLE_USER_PLUGINS'): core.BNInitUserPlugins() @@ -178,6 +181,13 @@ def _init_plugins(): _destruct_callbacks = _DestructionCallbackHandler() + +def disable_default_log(): + '''Disable default logging in headless mode for the current session. By default, logging in headless operation is controlled by the 'python.log.minLevel' settings.''' + global _enable_default_log + _enable_default_log = False + close_logs() + def bundled_plugin_path(): """ ``bundled_plugin_path`` returns a string containing the current plugin path inside the `install path <https://docs.binary.ninja/getting-started.html#binary-path>`_ |
