-
Notifications
You must be signed in to change notification settings - Fork 28
Home
Please click links from the right side bar to read what you are interested in.
1.Import via gradle, currently the latest version is
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.
If you want to know how this library works, this section may be the most helpful.
As the graph shown above, PLog work as a simple, linear procedure, some key nodes on this chain are:
decide whether this log can be printed.
decide which format should print for this log, e.g. JSON, Throwable, Object, etc.
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.
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.
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.