Matt Coneybeare

MC

UALogger 0.3 Released

| Comments

Lumberjack

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:

1
[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:

1
2
3
4
5
6
7
8
9
10
[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.

1
2
3
4
5
6
7
[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 posting helpful at all, I would really appreciate it if you would check out my Apps on the iTunes App Store.

Comments

My name is Matt Coneybeare, I design and develop for the web, iOS (iPhone, iPad and iPod Touch), and MacOS out of New York City. In 2008 I started a software company called Urban Apps that has made some pretty popular apps such as Ambiance and Hourly News. In 2019, I joined the team at Ticket Evolution as a Senior Software Engineer. My current Stack Overflow reputation is about 27k.

I was a Rockstar a decade ago, but then went back to school and collected a Bachelor's Degree in Computer Science from U.C. Berkeley and a MBA from Quantic. Now I am settled down with my beautiful wife Di and our dog Hamachi. When not at my desk, I love exploring New York City as a Yelp Elite, or training for marathons.

Contact information

Name
Matt Coneybeare
Email
Website
Twitter
Instagram
GitHub
LinkedIn
Strava