Latest 1.0.5
Homepage https://github.com/ankyhe/GRLogger
License MIT
Platforms ios
Authors

I started my iOS dev (it calls iPhone dev then) from May, 2009. I composed a logger utility for debugging
and tracing. I used them within 2 iOS apps and it gives me a lot of help. Today I want to open source it
to public.

License: MIT

Install:
(1) Add GRLogger.h, GRLogger.m and License into your project or
pod ‘GRLogger’, ‘~> 1.0.5’
(2) Sample — Please refer to main.m

#import "GRLogger.h"
int foo()
{
  ENTER(@"foo");
  RETURN(10, @"foo");
}

int main(int argc, char *argv[])
{
  @autoreleasepool {
    SETLOGLEVEL(SLLS_ALL);
    INFO(@"info");
    DBG(@"debug value is %d", 3);
    WARN(@"warning");
    ERROR(@"error");
    FATAL(@"fatal");
    LOG(SLL_TINY, @"tiny");
    foo();
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
   }
}

The output is as below:
2012-05-29 01:10:42.859 GRLogger[42610:f803] FILE:main.m LINE:25 [INFO] info
2012-05-29 01:10:42.867 GRLogger[42610:f803] FILE:main.m LINE:26 [DEBUG] debug value is 3
2012-05-29 01:10:42.868 GRLogger[42610:f803] FILE:main.m LINE:27 [WARN] warning
2012-05-29 01:10:42.869 GRLogger[42610:f803] FILE:main.m LINE:28 [ERROR] error
2012-05-29 01:10:42.870 GRLogger[42610:f803] FILE:main.m LINE:29 [FATAL] fatal
2012-05-29 01:10:42.872 GRLogger[42610:f803] FILE:main.m LINE:30 [TINY] tiny
2012-05-29 01:10:42.873 GRLogger[42610:f803] FILE:main.m LINE:17 [ENTER] foo
2012-05-29 01:10:42.874 GRLogger[42610:f803] FILE:main.m LINE:18 [RETURN] foo

Documentation:
(1) SETLOGLEVEL(SLLS_ALL);

typedef enum {
SLLS_ALL = 0,
SLLS_MAJOR = 45,
SLLS_MINOR = 65,
SLLS_NONE = 1000,
SLLS_DEFAULT = SLLS_MAJOR // SLLS_DEFAULT = SLLS_MAJOR
} GRLoggerLevelSetting;
If you set values other than GRLoggerLevelSetting, it uses SLLS_DEFAULT
Usually we use SLLS_ALL, SLLS_MAJOR (just INFO, WARN, ERROR, FATAL) and SLLS_NONE.

(2) If you want to close GRLogger, you have 2 approaches:

  • SETLOGLEVEL(SLLS_NONE);
  • defined __SELF_DEFING_CLOSEGRLOGGER__ (better)

TODO:
(1) Support log into files

Latest podspec

{
    "name": "GRLogger",
    "version": "1.0.5",
    "summary": "A handy logger library for iOS",
    "description": "                   A handy logger library:nn                   * Logger leveln                   * Handy macros, such as ENTERFUNC(), it can print the selector or function namen",
    "homepage": "https://github.com/ankyhe/GRLogger",
    "license": {
        "type": "MIT",
        "file": "GRLogger/License"
    },
    "authors": {
        "AnkyHe": "[email protected]"
    },
    "platforms": {
        "ios": null
    },
    "source": {
        "git": "https://github.com/ankyhe/GRLogger.git",
        "tag": "1.0.5"
    },
    "source_files": [
        "GRLogger/GRLogger.h",
        "GRLogger/GRLogger.m"
    ],
    "requires_arc": false
}

Pin It on Pinterest

Share This