-
Notifications
You must be signed in to change notification settings - Fork 8
Logging
Logging is a great resource for debugging, but care should be taken to control the amount of logs you are sending in release builds. Writing to the log file consumes game resources, and spamming messages to a log makes it harder to read and less useful for other users and developers.
Everest provides a static Logger
class that you can use to write messages to log.txt
. Logs are constructed of three parts:
-
Level: the urgency of the message.
- Verbose < Debug < Info < Warn < Error
- Defaults to
Verbose
if a level is not provided.
-
Tag: the category of the message. Tags are used to filter which logs get printed.
- Should be unique, but not long enough to clutter the log.
- The minimum level to log a tag is
Info
by default. Can be overridden withSetLogLevel
.
- Message: the actual log message.
if (level.Tracker.GetEntity<Player>() == null) {
Logger.Log(LogLevel.Warn, "MyMod/MyCustomEntity", "Oh no, can't find the player!");
return false;
}
In this example, Warn
is higher than our tag's minimum level, so the log will be printed:
(07/30/2022 21:09:02) [Everest] [Warn] [MyMod/MyCustomEntity] Oh no, can't find the player!
Here is a quick reference for common Logger
features:
Logger.Log(LogLevel level, string tag, string str) // Logs a message (if minimum level met).
Logger.Log(string tag, string str) // Logs a message at Verbose level.
Logger.LogDetailed(LogLevel level, string tag, string str) // Logs a message with a stack trace.
Logger.LogDetailed(string tag, string str) // Logs a message with a stack trace at Verbose level.
Logger.SetLogLevel(string tagPrefix, LogLevel minimumLevel) // Sets the minimum log level for a tag prefix.
Note that SetLogLevel
expects a tag prefix. A common setup is to have a single SetLogLevel
call in your module's Load()
function that applies to all of your tags, e.g. SetLogLevel("MyMod", LogLevel.Info)
. This lets you easily switch between Verbose
for debugging and Info
for release builds.
- Use the
logdetours
debug command to print all active hooks. - Use the
setloglevel [tagPrefix] [level]
debug command to override a tag's minimum log level.- This can also be set persistently by editing the
LogLevels
key in the Everest settings file.
- This can also be set persistently by editing the
- Use the
--loglevel
command line argument to set the default print level for all tags at launch. -
Console.WriteLine()
will print directly to the log file.⚠️ Handy for quick debugging, but do not use in a release build of your mod.
Home
Contributing
FAQ
Useful Links
Your First Custom Map
Your First Texture Pack
Mod Setup
Custom Maps
Texture Packs
Uploading Mods
Generated Dialog Keys
Reference Code Mod🔗
Vanilla Audio IDs
Vanilla Decal Registry Reference
Character Portraits
Mod Structure
Debug Mode
Debug Map
Command Line Arguments
Environment Variables
Install Issues
Common Crashes
Latency Guide
everest.yaml Setup
Mapping FAQ
Map Metadata
Vanilla Metadata Reference
Adding Custom Dialogue
Overworld Customisation
Entity & Trigger Documentation
Custom Entity List🔗
Camera
Ahorn Scripts
Custom Tilesets
Tileset Format Reference
Stylegrounds
Reskinning Entities
Skinmods
Decal Registry
Chapter Complete Screen
Custom Portraits
Adding Custom Audio
Advanced Custom Audio
Code Mod Setup
Making Code Mods
Settings, SaveData and Session
Everest Events
Understanding Input
Logging
Cross-Mod Functionality
Recommended Practices
Core Migration Guide
Lönn Integration🔗
Custom Events
Adding Sprites
Adding Preexisting Audio