Info Log
The Info method in the Cobra Logging system is your ally in tracking the narrative of your application.
At its heart, Info is a storyteller. It gives voice to your application's events. Instead of shouting errors, it calmly narrates what's happening, offering vital clues without the drama.
Parameters
- message: Your protagonist. This is the core tale you want to tell, whether it's "Player entered the room" or "Network connection initialized."
- state: The sidekick. It enriches your story, providing optional, additional data. Maybe it's the player's current score or the number of NPCs in a scene.
When to Narrate in Unity?
- Debugging Animations: Not sure when a specific animation starts or ends? Drop an Info log in the trigger functions.
- User Interactions: Curious about the paths players take? Log informational messages when they interact with game objects or UI elements.
- Scene Transitions: When a player moves between scenes, especially in large open-world settings, use Info to track these transitions smoothly.
- Network Activities: If you're working on a multiplayer setup, knowing when a player joins a lobby or sends a message can be invaluable.
- Resource Loading: When loading resources, especially asynchronously, Info logs can offer a breadcrumb trail of what assets have been loaded.
Example
Imagine you're developing a Unity game where a player enters a mysterious room:
void OnPlayerEnterRoom()
{
var playerData = new { Health = 100, InventoryCount = 5 };
Log.Info("Player has entered the mysterious room.", state: playerData);
}
Here, not only do you know when the player entered the room, but you also get a quick snapshot of their health and inventory count at that moment because the player data state is passed in.
Remember, while errors scream for attention, it's often the silent, informative whispers that hold the keys to understanding your application's journey. So, log wisely, and let Info be your guiding light in the dark corners of game development.