-
Notifications
You must be signed in to change notification settings - Fork 7
Mod Logger
The Cotton ModLogger allows you to write prettier logs.
Creating a new ModLogger couldn't be easier. Simply put the following code in your mod's main file:
public static ModLogger logger = new ModLogger(MODID);
And that's all there really is to it. But you might want to add a custom prefix to your logger so it's easier to recognize your mod's logs:
public static ModLogger logger = new ModLogger(MODID, "Foo");
Now everything this logger writes will have the prefix "[Foo]: "
A ModLogger comes with different levels, which makes it easier to only log what you need. You can log using a level by writing: logger.level("Hello World!")
.
Each level has a different priority and some of them also have special colors to make them more visible.
To make your prefix even more unique you can add custom ASCI formats to it. The following example will make the prefix bold and green:
logger.setPrefixFormat(Ansi.Bold.and(Ansi.Green));