https://github.com/calvindd2f/logutil
https://github.com/calvindd2f/logutil
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/calvindd2f/logutil
- Owner: Calvindd2f
- Created: 2024-07-13T17:05:36.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-31T21:35:52.000Z (over 1 year ago)
- Last Synced: 2025-01-01T05:17:59.589Z (over 1 year ago)
- Language: C++
- Size: 3.23 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# CSharp usage example
Source code is in C++ and compiled with Zig c++.
```cs
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Runtime.CompilerServices;
internal static class LogUtil
{
private const string DllName = "logutil.dll"; // or the full path to the DLL
[SuppressUnmanagedCodeSecurity]
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool LogInfo(string shortMessage, [MarshalAs(UnmanagedType.U1)] bool detailedDescription);
[SuppressUnmanagedCodeSecurity]
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool LogError(string shortMessage, [MarshalAs(UnmanagedType.U1)] bool detailedDescription);
[SuppressUnmanagedCodeSecurity]
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool LogWarning(string shortMessage, [MarshalAs(UnmanagedType.U1)] bool detailedDescription);
[SuppressUnmanagedCodeSecurity]
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool LogVerbose(string shortMessage, [MarshalAs(UnmanagedType.U1)] bool detailedDescription);
[SuppressUnmanagedCodeSecurity]
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool LogDebug(string shortMessage, [MarshalAs(UnmanagedType.U1)] bool detailedDescription);
}
class Program
{
static void Main()
{
LogUtil.LogInfo("Test Info", false);
LogUtil.LogError("Test Error", true);
LogUtil.LogWarning("Test Warning", false);
LogUtil.LogVerbose("Test Verbose", true);
LogUtil.LogDebug("Test Debug", false);
Console.WriteLine("Logging completed.");
}
}
```