High-performance Unity logging plugin based on spdlog, providing cross-platform native logging functionality.
- High Performance - Asynchronous logging system based on spdlog with minimal impact on game performance
- File Rotation - Automatic log file size and count management to prevent oversized log files
- Multi-Platform - Supports Windows, Linux, macOS, Android, and iOS
- Flexible Configuration - Configurable log levels, file paths, async mode, and more
- Editor Tools - Integrated Unity Editor configuration interface and log viewer
- Auto Initialization - Supports automatic runtime initialization without manual calls
- Unity Integration - Seamless integration with Unity logging system, automatically captures Debug.Log/Error/Warning
- Windows - x86, x86_64
- Linux - x86, x86_64
- macOS - x86_64, arm64
- Android - armeabi-v7a, arm64-v8a, x86, x86_64
- iOS - arm64
MLogger/
├── native/ # C++ native layer (based on spdlog)
│ ├── src/ # Source code
│ │ ├── core/ # Core logger manager
│ │ ├── bridge/ # C interface bridge
│ │ └── utils/ # Utility classes (path and string utilities)
│ ├── tests/ # Native layer test suites
│ └── external/ # Third-party dependencies (spdlog)
├── unity/ # Unity C# plugin layer
│ └── Assets/
│ └── Plugins/
│ └── MLogger/
│ ├── Runtime/ # Runtime scripts
│ ├── Editor/ # Editor tools
│ └── External/ # Native library files
└── scripts/ # Build and automation scripts
└── compile/ # Compilation scripts
- Python 3.6+
- CMake 3.20+
- Platform-specific build toolchain (Visual Studio, GCC, Xcode, etc.)
The build script supports several options:
# Force clean build (removes CMake cache)
python scripts/compile/build.py --platform linux --clean
# Build with tests
python scripts/compile/build.py --platform linux --test
# Build with retry on failure
python scripts/compile/build.py --platform linux --retry 3python scripts/compile/build.py --all# Linux
python scripts/compile/build.py --platform linux
# Windows
python scripts/compile/build.py --platform windows
# macOS
python scripts/compile/build.py --platform macos
# Android
python scripts/compile/build.py --platform android
# iOS
python scripts/compile/build.py --platform iospython scripts/compile/build.py --platform linux --arch x86_64After building, library files will be automatically copied to unity/Assets/Plugins/MLogger/External/ for the corresponding platform.
MLogger supports automatic initialization. Simply configure it in Unity Editor:
- Open Edit > Project Settings > MLogger
- Configure log path, file size, log level, etc.
- Run the game, logs will be automatically recorded to files
using MLogger;
using UnityEngine;
public class Example : MonoBehaviour
{
void Start()
{
// Use Unity standard logging interface, MLogger will automatically capture
Debug.Log("This is an info log");
Debug.LogWarning("This is a warning log");
Debug.LogError("This is an error log");
// Check initialization status
if (MLoggerManager.IsInitialized)
{
Debug.Log($"Log file path: {MLoggerManager.CurrentConfig.logPath}");
}
// Manually set log level
MLoggerManager.SetLogLevel(LogLevel.Warning);
// Flush log buffer
MLoggerManager.Flush();
}
}If you need manual control over initialization:
var config = new MLoggerConfig
{
logPath = "Logs/game.log",
maxFileSize = 10 * 1024 * 1024, // 10MB
maxFiles = 5,
asyncMode = true,
minLogLevel = LogLevel.Info
};
MLoggerManager.Initialize(config);- logPath - Log file path (default: platform-specific path)
- maxFileSize - Maximum size of a single log file (default: 10MB)
- maxFiles - Number of log files to keep (default: 5)
- asyncMode - Whether to use async mode (default: true)
- threadPoolSize - Thread pool size for async mode (default: 2)
- minLogLevel - Minimum log level (default: Info)
- autoInitialize - Whether to auto-initialize (default: true)
- alsoLogToUnity - Whether to also output to Unity Console (default: true)
Trace- Most detailed logsDebug- Debug informationInfo- General informationWarning- WarningsError- ErrorsCritical- Critical errors
In Edit > Project Settings > MLogger, you can:
- Configure log path, file size, and count
- Set log level and async mode
- View runtime status
- Open log directory with one click
- Manually flush log buffer
In Window > MLogger > Log Viewer, you can:
- View log file content in real-time
- File Selection - Switch between multiple log files (including rotated historical files)
- Level Filtering - Filter logs by level (Trace/Debug/Info/Warn/Error/Critical)
- Advanced Search - Search with keywords or regular expressions
- Syntax Highlighting - Color-coded log levels for better readability
- Auto-refresh - Automatically refresh log content at configurable intervals
- Statistics - View log statistics (total lines, counts by level, file size)
- Export - Export filtered logs as text or CSV files
- Clean Tools - Clean log files by size, time, or count
The project includes comprehensive test suites:
Located in native/tests/, including:
- Basic Tests (
test_mlogger.cpp) - Core functionality tests - Boundary Tests (
test_boundary.cpp) - Edge cases and extreme configurations - Error Handling (
test_error_handling.cpp) - Invalid paths, permission issues, etc. - Stress Tests (
test_stress.cpp) - High-frequency logging and concurrency tests - Memory Tests (
test_memory.cpp) - Memory operations and edge cases
Run tests with:
python scripts/compile/build.py --platform linux --testTest scripts are located in unity/Assets/Plugins/MLogger/Demo/ for runtime testing.
The project includes complete example scenes and test scripts located in unity/Assets/Plugins/MLogger/Demo/.
This project uses the same license as spdlog. See the LICENSE file for details.


