i’ve been using SOSmax for a while in my flash projects and i can tell you, it rocks!!, it’s a very handy debugger tool for developers, i found that someone already has created a class for Objective-C called SOSLog and comes with the following features:
- Different log levels You can use the levels Trace, Debug, Info, Warn, Error and Fatal.
- Global log level Set a threshold for all components from Off up to Fatal.
- Individual log level for each component Set each component’s (class) log level individually. This can be done at application startup or any later time.
- Configurable log messages Each log message can be printed with log level, component’s name or line number.
- Works with the iPhone simulator and test devices To use a test device only the ip of your system has to be set.
- No overhead in the release version of an app SOSLog doesn’t contain any implementation when a release version is build.
- SOS max features
here is how you can use it in your project:
The easiest way copy all the source files into your project, yes i know!!! … ”it should be avoided when possible since it’s inherently redundant and contrary to the goal of keeping “common code” modular and atomic. ” for those people you can go here and here. XD
- Download source codes form here.
- create a new View-Based Application project in xcode and name it: SOSLogDemo.
- in your project create a new group, name it SOSLog.
- inside this group add AbstractSocket.h, AbstractSocket.m, Socket.h, Socket.m, SOSLog.h and SOSLog.m.
- click Project -> Edit Project Settings.
- click the build tab.
- SOSLOGGING boolean variable has to be defined for use when preprocessing. Preprocessor Macro = SOSLOGGING=1 for within the debug configurtion Preprocessor Macro = SOSLOGGING=0 for within the release configuration
- import SOSlog.h in to SOSLogDemoAppDelegate.m.
- repleace the function applicationDidFinishLaunchingWithOptions with this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
- import SOSlog.h in to SOSLogDemoViewController.m
- repleace the function viewDidLoad with this:
1 2 3 4 5
notice that you should enable each component.
[SOSLog setLogLevel:sos_Trace forComponent:@__FILE__]; // this file's name [SOSLog setLogLevel:sos_Trace forComponent:@"SOSLogDemoViewController.m"];
when you compile and run, you should see something like this:
as you can see, it’s very easy to get SOSLog working in your project.