Logging - simple-entertainment/simplicity GitHub Wiki

The logging API provides an abstraction layer for interacting with the console and files etc. for the purpose of logging information. It is very complicated to use so listen carefully:

Logs::log(MyCategories::PERFORMANCE_LOG, "This is taking a very long time...");

Done, that's how you log information :)

You can use any categories you like. Simplicity does, however, provide you with the log4j-esque logging categories:

  • Category::DEBUG_LOG
  • Category::ERROR_LOG
  • Category::FATAL_LOG
  • Category::INFO_LOG
  • Category::TRACE_LOG

Resources

So where does the information you log end up? You can specify a resource:

Resource* performanceLog = Resources::get("performance.txt", MyCategories::LOGS);
Logs::setResource(performanceLog, MyCategories::PERFORMANCE_LOG);

Also, you can add a default resource that will be used for all categories that don't have a resource explicitly bound to them:

Resource* someResource = // Some resource...
Logs::setResource(someResource, MyCategories::ALL_CATEGORIES);