Search in sources :

Example 6 with AndroidLogAdapter

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");
}
Also used : HashMap(java.util.HashMap) AndroidLogAdapter(com.orhanobut.logger.AndroidLogAdapter) FormatStrategy(com.orhanobut.logger.FormatStrategy) PrettyFormatStrategy(com.orhanobut.logger.PrettyFormatStrategy) DiskLogAdapter(com.orhanobut.logger.DiskLogAdapter)

Example 7 with AndroidLogAdapter

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));
}
Also used : AndroidLogAdapter(com.orhanobut.logger.AndroidLogAdapter) CsvFormatStrategy(com.orhanobut.logger.CsvFormatStrategy) FormatStrategy(com.orhanobut.logger.FormatStrategy) PrettyFormatStrategy(com.orhanobut.logger.PrettyFormatStrategy) DiskLogAdapter(com.orhanobut.logger.DiskLogAdapter)

Aggregations

AndroidLogAdapter (com.orhanobut.logger.AndroidLogAdapter)7 FormatStrategy (com.orhanobut.logger.FormatStrategy)4 PrettyFormatStrategy (com.orhanobut.logger.PrettyFormatStrategy)4 DiskLogAdapter (com.orhanobut.logger.DiskLogAdapter)2 Intent (android.content.Intent)1 AppCrashHandler (com.example.test.andlang.log.AppCrashHandler)1 CsvFormatStrategy (com.orhanobut.logger.CsvFormatStrategy)1 RxPermissions (com.tbruyelle.rxpermissions2.RxPermissions)1 HashMap (java.util.HashMap)1