Search in sources :

Example 1 with FormatStrategy

use of com.orhanobut.logger.FormatStrategy in project android-mdm-agent by flyve-mdm.

the class MDMAgent method onCreate.

/**
 * Called when the application is starting before any activity, service or receiver objects have been created
 */
@Override
public void onCreate() {
    super.onCreate();
    instance = this;
    UtilsCrash.configCrash(this, true);
    try {
        FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder().tag(// (Optional) Global tag for every log.
        getPackageName()).build();
        Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
    } catch (Exception ex) {
        ex.getStackTrace();
    }
    // ( 0 != ( getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
    isDebuggable = true;
}
Also used : AndroidLogAdapter(com.orhanobut.logger.AndroidLogAdapter) FormatStrategy(com.orhanobut.logger.FormatStrategy) PrettyFormatStrategy(com.orhanobut.logger.PrettyFormatStrategy)

Example 2 with FormatStrategy

use of com.orhanobut.logger.FormatStrategy in project 91Pop by DanteAndroid.

the class AppLogger method initLogger.

public static void initLogger() {
    FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder().showThreadInfo(false).methodCount(0).methodOffset(5).build();
    Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) {

        @Override
        public boolean isLoggable(int priority, String tag) {
            return BuildConfig.DEBUG;
        }
    });
}
Also used : AndroidLogAdapter(com.orhanobut.logger.AndroidLogAdapter) FormatStrategy(com.orhanobut.logger.FormatStrategy) PrettyFormatStrategy(com.orhanobut.logger.PrettyFormatStrategy)

Example 3 with FormatStrategy

use of com.orhanobut.logger.FormatStrategy 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 4 with FormatStrategy

use of com.orhanobut.logger.FormatStrategy 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)4 FormatStrategy (com.orhanobut.logger.FormatStrategy)4 PrettyFormatStrategy (com.orhanobut.logger.PrettyFormatStrategy)4 DiskLogAdapter (com.orhanobut.logger.DiskLogAdapter)2 CsvFormatStrategy (com.orhanobut.logger.CsvFormatStrategy)1 HashMap (java.util.HashMap)1