UALogger 0.3 Released

2 minute read

UALogger is a logging tool for iOS and Mac apps. Think of it as NSLog on steroids. It allows you to add information like the file and line number to your logs, customize when to log to the console and when not to, and allows collection of the entire recent console log for your application. It includes the UALogger class and class methods, and a few handy macros.

I just finished updating a cool feature in UALogger: Severity Level Filtering.

As of version 0.3, UALogger can be setup to work with log severity levels. Each of the three logging macros (UALogPlain, UALogBasic, and UALogFull), as well as the shorthand macro (UALog), has a new variation that lets you pass in a UALoggerSeverity

  • UASLogPlain
  • UASLogBasic
  • UASLogFull
  • UASLog (Defaults to UASLogBasic)

The S stands for severity, and is the first argument in those functions. UALogger recognizes 5 severities:

  • UALoggerSeverityDebug (Lowest log level)
  • UALoggerSeverityInfo
  • UALoggerSeverityWarn
  • UALoggerSeverityError
  • UALoggerSeverityFatal (Highest Log Level)

To use the severity levels, you MUST set a minimumSeverity for UALogger to use:

[UALogger setMinimumSeverity:UALoggerSeverityWarn];

By default, the severity is UALoggerSeverityUnset and thus, not used for determining when to log. When unset, the [UALogger loggingEnabled] method is used. Once you set the minimumSeverity to something else however, ONLY the verbosity specified will be used to determine when to log. For example:

[UALogger setMinimumSeverity:UALoggerSeverityWarn];
UASLog(UALoggerSeverityDebug, @"Logged with severity => UALoggerSeverityDebug");
UASLog(UALoggerSeverityInfo, @"Logged with severity => UALoggerSeverityInfo");
UASLog(UALoggerSeverityWarn, @"Logged with severity => UALoggerSeverityWarn");
UASLog(UALoggerSeverityError, @"Logged with severity => UALoggerSeverityError");
UASLog(UALoggerSeverityFatal, @"Logged with severity => UALoggerSeverityFatal");

> Logged with severity => UALoggerSeverityWarn
> Logged with severity => UALoggerSeverityError
> Logged with severity => UALoggerSeverityFatal

Only 3 of the above lines are logged because they meet or exceed the minimum severity of UALoggerSeverityWarn

After setting the minimumSeverity, any calls made to the non-S functions will not log unless you unset it.

[UALogger setMinimumSeverity:UALoggerSeverityDebug];
UALog(@"This will not log.");
UASLog(UALoggerSeverityDebug, @"This will log.");

[UALogger setMinimumSeverity:UALoggerSeverityUnset];
UALog(@"This will log.");
UASLog(UALoggerSeverityDebug, @"This will log, and the severity ignored");

Check out the new version of UALogger on Github and let me know what you think!

Lastly, I run a small software company called Urban Apps. It pays the bills so I can take the time to write helpful utilities like UALogger. If you found this page helpful at all, I would really appreciate it if you would check out my Apps on the iTunes App Store.

Was this page helpful for you? Buy me a slice of 🍕 to say thanks!

Comments