Table of Contents

Switchboard

Switchboard is a high performance logging framework, with dependency injection, built for the Unity game engine. Switchboard will automatically create rotating log files on any hardware platform, with almost no measurable impact on performance. No garbage memory is allocated in the process, and you can log thousands of log entries per frame without affecting gameplay. Log files for Android, iOS, and other platforms are no problem.

Manipulating strings of text without garbage memory allocation is made possible by StringMaker, a direct replacement for StringBuilder. In Unity, StringBuilder allocates garbage memory when appending number variables. StringMaker can append numbers without allocation, in every imaginable format, even those not supported by .NET. Standard .NET code is simply not capable of displaying certain number values. A float can never display more than nine significant digits, for example. Even the debugger is inaccurate. StringMaker renders perfectly accurate floating-point numbers that show the true decimal representation of what is actually stored in binary. StringMaker is compatible with TextMesh Pro, so you can even update the text in your game without allocating any garbage memory.

Dependency injection for Unity is built in. Switchboard provides a composition root where you can define the code that runs when you play the game, no matter which scene is loaded. From there, you can inject dependencies, like the logger, into MonoBehaviours with a loosely coupled interface. No need to directly reference a specific class dependency. This helps keep your code modular, and allows for unit testing with mock dependencies. You'll never need another singleton, or to load a certain scene to initialize your game. Play testing in any scene is easy. Switchboard is designed for disabling domain reload and scene reload, so you can enter play mode instantly. Your composition root properties can be changed easily in the editor, perfect for testing and experimentation, and you will not lose any changes when you stop playing, as with scene data. An innovative design pattern allows Switchboard to completely avoid the costly reflection and code generation that other frameworks use.

Modular dependencies are key, so Switchboard is designed for you to only use the features you need. For example, if you want log files, but not dependency injection, removing or replacing the unwanted modules is easy. Each feature is built with modularity in mind, so you only import what you actually need.

Switchboard is available on the Unity Asset Store.