use of com.orhanobut.logger.AndroidLogAdapter in project logger by orhanobut.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("Tag", "I'm a log which you don't see easily, hehe");
Log.d("json content", "{ \"key\": 3, \n \"value\": something}");
Log.d("error", "There is a crash somewhere or any warning");
Logger.addLogAdapter(new AndroidLogAdapter());
Logger.d("message");
Logger.clearLogAdapters();
FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder().showThreadInfo(// (Optional) Whether to show thread info or not. Default true
false).methodCount(// (Optional) How many method line to show. Default 2
0).methodOffset(// (Optional) Skips some method invokes in stack trace. Default 5
3).tag(// (Optional) Custom tag for each log. Default PRETTY_LOGGER
"My custom tag").build();
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
Logger.addLogAdapter(new AndroidLogAdapter() {
@Override
public boolean isLoggable(int priority, String tag) {
return BuildConfig.DEBUG;
}
});
Logger.addLogAdapter(new DiskLogAdapter());
Logger.w("no thread info and only 1 method");
Logger.clearLogAdapters();
formatStrategy = PrettyFormatStrategy.newBuilder().showThreadInfo(false).methodCount(0).build();
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
Logger.i("no thread info and method info");
Logger.t("tag").e("Custom tag for only one use");
Logger.json("{ \"key\": 3, \"value\": something}");
Logger.d(Arrays.asList("foo", "bar"));
Map<String, String> map = new HashMap<>();
map.put("key", "value");
map.put("key1", "value2");
Logger.d(map);
Logger.clearLogAdapters();
formatStrategy = PrettyFormatStrategy.newBuilder().showThreadInfo(false).methodCount(0).tag("MyTag").build();
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
Logger.w("my log message with my tag");
}
use of com.orhanobut.logger.AndroidLogAdapter in project MyNewCC98 by 6769.
the class LogUtil method initLogger.
public static void initLogger() {
FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder().showThreadInfo(// (Optional) Whether to show thread i or not. Default true
true).tag(// (Optional) Global tag for every log. Default PRETTY_LOGGER
"My98").build();
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
FormatStrategy diskformatStrategy = CsvFormatStrategy.newBuilder().tag("MyCC98").build();
Logger.addLogAdapter(new DiskLogAdapter(diskformatStrategy));
}
Aggregations