From 8a4c314a7e9f8ce98b93206fea2cfb07aaf46986 Mon Sep 17 00:00:00 2001 From: tinysec Date: Thu, 23 Jul 2026 03:56:37 +0800 Subject: [PATCH] Add core log routing controls --- Logging.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Logging.cs diff --git a/Logging.cs b/Logging.cs new file mode 100644 index 0000000..a388fc5 --- /dev/null +++ b/Logging.cs @@ -0,0 +1,42 @@ +using System; + +namespace BinaryNinja +{ + public static partial class Core + { + /// Routes messages at or above the given level to standard output. + public static void LogToStdout(LogLevel minimumLevel) + { + NativeMethods.BNLogToStdout(minimumLevel); + } + + /// Routes messages at or above the given level to standard error. + public static void LogToStderr(LogLevel minimumLevel) + { + NativeMethods.BNLogToStderr(minimumLevel); + } + + /// Routes messages at or above the given level to a file. + public static bool LogToFile(LogLevel minimumLevel, string path, bool append = false) + { + if (null == path) + { + throw new ArgumentNullException(nameof(path)); + } + + return NativeMethods.BNLogToFile(minimumLevel, path, append); + } + + /// Notifies registered listeners that their configuration may have changed. + public static void UpdateLogListeners() + { + NativeMethods.BNUpdateLogListeners(); + } + + /// Flushes and closes every core-managed log destination. + public static void CloseLogs() + { + NativeMethods.BNCloseLogs(); + } + } +}