Logging
Geode provides a builtin logger with fmtlib formatting, which you can view in real time via the platform console, or later on by checking the logs in the:
<GD FOLDER>/geode/logs
directory onWindows
andMacOS
Android/media/com.geode.launcher/game/geode/logs
directory onAndroid
Log Levels
There are 4 logging levels, each being more important than the previous.
⚠️ If you want to omit
geode::
from the log call, you can useusing namespace geode::prelude
at the top of your file
Error
This is the highest priority level, used for logging errors that interrupt your mod’s functionality, without recovery. As examples, the following cases apply: an API call failing, not finding a node in a specific layer that you need, etc. Use this level sparingly.
geode::log::error("I am a grave error!");
Warn
This level is used for warning about certain aspects of your mod that failed, but aren’t critical to its functionality / can be recovered from. For example, an API request failing (but the mod retries the connection), some non-vital setting or saved value not being set that you have a default for, etc.
geode::log::warn("I failed to fetch this list of items, but I'll retry a few times");
Info
This level is used for logging information about what your mod is doing. You shouldn’t use this level to spam info messages, just simple information. For example, messages like “Loading assets for scene” are suitable, but “Coordinates: {120.3, 150.3}” being spammed over and over should be set to the lowest logging level.
geode::log::info("Setting up the editor adjustments");
Debug
Use this level for anything you find useful to log! May that be values used in your mod, more specific text, and going into more detail than the info level. For example, while for info
we logged something like “Loading assets for scene”, for debug
we can log “Loading spritesheet MyModSheet.png” or the coordinates message from above.
geode::log::debug("Loading sheet {}", sheetName);
geode::log::debug("Filesize: {}", filesize);
geode::log::debug("Found node: {}", node->getID());
⚠️ Debug logs are not shown by default. See the Log filtering section to see how you can change this behavior.
Syntax
The logger uses fmtlib under the hood, which means you can use its syntax, which will get forwarded to fmtlib. Geode also provides formatters for a few common types, such as CCPoint
, CCNode
, etc.
Image from https://hackingcpp.com
As such, you are able to do things like this:
geode::log::debug("Hello {:>10.3f} world, [{}]", 12.4f, fmt::join(someVec, ", "));
Platform console
The platform console is the quickest way to see the logs, running real time ingame. You can open the platform console by going to the Geode settings.
Log filtering
Log filtering is a system that hide the less important logs from the platform console and the log files generated by Geode. The log level can be customized individually for both of these output locations, so you can have a log level of info for the log files, and a log level of debug for the platform console.
The log level takes the value debug, info, warn or error. Setting the log level to one of those values will only allow logs with that level or higher to be written. For example, log level warn will only show warns and errors, while log level info will show info, warn and error logs. The default values of those log levels is info for both channels.
You can modify your log levels ingame, through Geode’s settings.