| name | f8-features-log-workflow |
| description | Use when implementing or troubleshooting Log feature workflows — logging, file writing, error reporting, LogViewer, and debug commands in F8Framework. |
Log Feature Workflow
⚠️ IMPORTANT: Before using this feature, you MUST formally initialize F8Framework in the launch sequence. Ensure ModuleCenter.Initialize(this); has run first, then create the required module, for example FF8.LogWriter = ModuleCenter.CreateModule<F8LogWriter>();.
Use this skill when
- The task is about logging, debug output, file-based log writing, or error reporting.
- The user asks about LogViewer, cheat codes, or debug commands.
Path resolution
- Prefer project source at Assets/F8Framework.
- For usage docs, read: Assets/F8Framework/Tests/Log/README.md
Sources of truth
- Runtime module: Assets/F8Framework/Runtime/Log
- Test docs: Assets/F8Framework/Tests/Log
Key classes and interfaces
| Class | Role |
|---|
LogF8 | Static logging class. Multiple log channels and utility methods. |
LogWriter | Module for file-based log writing. Access via FF8.LogWriter. |
Function | LogViewer command system. |
API quick reference
Basic logging
LogF8.Log(message);
LogF8.Log("Format {0}", 1);
LogF8.Log("Message", this);
LogF8.LogNet("Network {0}", "data");
LogF8.LogEvent(data);
LogF8.LogConfig(data);
LogF8.LogView(data);
LogF8.LogEntity(data);
LogF8.LogStackTrace("Stack trace");
Thread-safe logging
LogF8.LogToMainThread("From background thread");
LogF8.LogErrorToMainThread("Error from background thread");
Log control
LogF8.EnabledLog();
LogF8.DisableLog();
File writing
FF8.LogWriter.OnEnterGame();
Error capture
LogF8.GetCrashErrorMessage();
Performance monitoring
LogF8.Watch();
LogF8.Log(LogF8.UseMemory);
LogF8.Log(LogF8.UseTime);
LogViewer commands
Function.Instance.AddCommand(this, "MethodName", new object[] { param });
Function.Instance.AddCheatKeyCallback((cheatKey) =>
{
LogF8.Log("Cheat: " + cheatKey);
});
LogViewer activation
- Keyboard: press tilde key
~
- Mobile: five-finger long press for 1 second
Workflow
- Use
LogF8.Log() for general-purpose debug output.
- Use channel-specific methods for organized logging (Net, Event, Config, View, Entity).
- Enable file writing with
FF8.LogWriter.OnEnterGame() for production logging.
- Add
GetCrashErrorMessage() for crash error capture.
- Add LogViewer to scene for runtime debug console.
- Register debug commands via
Function.Instance.AddCommand().
Common error handling
| Error | Cause | Solution |
|---|
| Logs not appearing | DisableLog() was called | Call EnabledLog() |
| File write permission | No write access to log directory | Ensure persistentDataPath is writable |
| Background thread log crash | Using Unity API from background thread | Use LogToMainThread() instead |
| LogViewer not showing | Component not in scene | Add LogViewer GameObject or load as asset |
Cross-module dependencies
- None — Log is a foundational utility used by all modules.
Output checklist
- Logging pattern selected (channel-based, file-based, error capture).
- LogViewer configuration documented.
- Files changed and why.
- Validation status and remaining risks.