Skip to content
Muyangmin edited this page Sep 11, 2016 · 10 revisions

Welcome to the Android-PLog wiki!

Please click links from the right side bar to read what you are interested in.

Basic Usage

1.Import via gradle, currently the latest version is Download

    compile 'org.mym.plog:android-plog:${latestVersion}'

2.Initialize PLog before any log**(Optional)**. Typical usage:

        PLog.init(new PLogConfig.Builder()
                .forceConcatGlobalTag(true)
                .keepInnerClass(true)
                .keepLineNumber(true)
                .useAutoTag(true)
                .maxLengthPerLine(160)
                .build());

All settings are optional, and here just show a few part of options.Please see doc for advanced usage.
3.Use PLog class to print log, via v(), d(), i() method, and so on. Sample:

        PLog.empty();
        PLog.v("This is a verbose log.");
        PLog.d("DebugTag", "This is a debug log.");
        PLog.e("This is an error log.");

        PLog.resetTimingLogger();
        PLog.addTimingSplit("Timing operation");
        PLog.dumpTimingToLog();

For more sample codes please see app module on this repository.

Flow Graph

If you want to know how this library works, this section may be the most helpful. FlowGraph

As the graph shown above, PLog work as a simple, linear procedure, some key nodes on this chain are:

Controller

decide whether this log can be printed.

Formatter

decide which format should print for this log, e.g. JSON, Throwable, Object, etc.

MsgWrapper

add decor information for formatted log.
As of version 1.5.0, the only type of decor information is LineNumber info. However, if user disables keepLineNumber option, this step change nothing actually. And this is why there are a star on the item in the graph above.

LineWrapper

soft line wrap for this log; this is where maxLengthPerLine option affects. if user defines a very large value, then line wrapper becomes actually useless.

Logger

this is the final step of printing log. User can define veriaty type of different loggers, such as standard logger, file logger, network logger, or event print to a TextView. There is a sample in the MainActivity class.

Clone this wiki locally