From 11b2cfa087f5de09b97eb42fb219f563886f6d40 Mon Sep 17 00:00:00 2001 From: Joel Stålnacke Date: Sun, 13 Oct 2024 14:32:14 +0300 Subject: Add libdjup logging --- Djup.Native/LibDjup.cs | 6 ++++++ Djup.Native/Types.cs | 12 ++++++++++++ 2 files changed, 18 insertions(+) (limited to 'Djup.Native') diff --git a/Djup.Native/LibDjup.cs b/Djup.Native/LibDjup.cs index fece18a..0ecf7a8 100644 --- a/Djup.Native/LibDjup.cs +++ b/Djup.Native/LibDjup.cs @@ -16,6 +16,12 @@ public static partial class LibDjup [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(get_vec2))] public static partial Vec2 get_vec2(); + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(log_set_output))] + public static partial Vec2 log_set_output([MarshalAs(UnmanagedType.FunctionPtr)] LoggerDelegate logger); + + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(log_set_level))] + public static partial Vec2 log_set_level(LogLevel minLevel); + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(world_create))] public static partial IntPtr world_create(); diff --git a/Djup.Native/Types.cs b/Djup.Native/Types.cs index c930bd6..572277f 100644 --- a/Djup.Native/Types.cs +++ b/Djup.Native/Types.cs @@ -39,3 +39,15 @@ public struct Ball public Vec2 Position { get; set; } public Vec2 Velocity { get; set; } } + +public enum LogLevel +{ + Trace, + Debug, + Info, + Warn, + Error, + Fatal +} + +public delegate void LoggerDelegate(LogLevel level, string source, int line, string message); -- cgit v1.2.3