| 4 | |
| 5 | namespace Runity { |
| 6 | public class Logging { |
| 7 | private DLog m_cbLog; |
| 8 | public Logging() { |
| 9 | m_cbLog = CallbackLog; |
| 10 | bind_log_callback(m_cbLog); |
| 11 | } |
| 12 | |
| 13 | public void CallbackLog(LogMessage a_message) { |
| 14 | switch(a_message.level) { |
| 15 | case Level.Error: |
| 16 | UnityEngine.Debug.LogError("[RUST] ERROR: " + a_message.message); |
| 17 | break; |
| 18 | case Level.Warn: |
| 19 | UnityEngine.Debug.LogWarning("[RUST] WARN: " + a_message.message); |
| 20 | break; |
| 21 | case Level.Info: |
| 22 | UnityEngine.Debug.Log("[RUST] INFO: " + a_message.message); |
| 23 | break; |
| 24 | case Level.Debug: |
| 25 | UnityEngine.Debug.Log("[RUST] DEBUG: " + a_message.message); |
| 26 | break; |
| 27 | case Level.Trace: |
| 28 | UnityEngine.Debug.Log("[RUST] TRACE: " + a_message.message); |
| 29 | break; |
| 30 | } |
| 31 | } |
| 32 | [DllImport("runity")] public static extern void bind_log_callback([MarshalAs(UnmanagedType.FunctionPtr)] DLog a_callback); |
| 33 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] |
| 34 | public delegate void DLog(LogMessage a_message); |
| 35 | } |
| 36 | |
| 37 | [StructLayout(LayoutKind.Sequential)] |
| 38 | public struct LogMessage { |
nothing calls this directly
no outgoing calls
no test coverage detected