Home

Awesome

FSLogger

An Android Logger with a lot of options for debugging that helps a lot to developers. You can easily add logs everywhere in your APP and manage showing them by limit them by Codes or by their Class name. It also will show you that logs was called from which file and which line, you also can see which class and which line called your current method.

alt tag

Gradle:

compile 'com.github.omegasoft7.FSLogger:fslogger:1.9.1'

##Iniatialization: for initialization you just need to add following line into your Application class.

//initialize FSLogger
FSLogger.init("MyAwesomeAPP");

##Types of Limitation: -)You can set different types for make limitation of showing logs.

You can set your type like following in your Application class:

FSLogger.setType(FSLogger.FSLoggerLimitationType.NOLimit);

##Usage: You have different options to use it.

FSLogger.logout("your log message");

//Result:
//[MainActivity.onClick()-336]: your log message
FSLogger.logout();

//Result:
//[MainActivity.onClick()-336]:
//Specify code in Application class like:
//FSLogger.addCode(12);
FSLogger.logout(12);

//Result:
//[MainActivity.onClick()-336]:
//Specify code in Application class like:
//FSLogger.addCode(12);

FSLogger.logout(12);

//Result:
//[MainActivity.onClick()-336]:

##Log Levels: You have a few options for logging

##Check Caller of our current function: If you want to see which class and in which line called your current message you have to add following code into your Application class:

//Result Before:
//[ClassB.test()-120]: your log message

FSLogger.enableLoggingWithBackTrace();

//Result After:
//[MainActivity.onClick()-336]: [ClassB.test()-120]: your log message

Crashlytics

If you are using Crashlytics(Fabric.io), you can implement a log collector in Application class for your crashlytics like following:

FSLogger.disable();
FSLogger.setListener(new FSLoggerListener() {
    @Override
    public void logout(FSLoggerLogType fsLoggerLogType, String tag, String message) {
        logCrashlytics(fsLoggerLogType, tag, message);
    }
    
    @Override
    public void logoutUnsuccess(FSLoggerLogType fsLoggerLogType, String tag, String message) {
        logCrashlytics(fsLoggerLogType, tag, message);
    }
    
    private void logCrashlytics(FSLoggerLogType fsLoggerLogType, String tag, String message) {
        int log;
        switch (fsLoggerLogType) {
            case Debug:
                log = Log.DEBUG;
                break;
            case Error:
                log = Log.ERROR;
                break;
            case Info:
                log = Log.INFO;
                break;
            case Verbose:
                log = Log.VERBOSE;
                break;
            case Warn:
                log = Log.WARN;
                break;
            case WTF:
                log = Log.VERBOSE;
                break;
            default:
                log = Log.VERBOSE;
        }
        Crashlytics.log(log, tag, message);
    }
});

License

Apache 2.0