Example usage for android.util Log INFO

List of usage examples for android.util Log INFO

Introduction

In this page you can find the example usage for android.util Log INFO.

Prototype

int INFO

To view the source code for android.util Log INFO.

Click Source Link

Document

Priority constant for the println method; use Log.i.

Usage

From source file:com.cbsb.ftpserv.Util.java

public static String ipToString(int addr) {
    if (addr == 0) {
        // This can only occur due to an error, we shouldn't blindly
        // convert 0 to string.
        myLog.l(Log.INFO, "ipToString won't convert value 0");
        return null;
    }//from  w  w w.  ja v a 2s  . c  o  m
    return ipToString(addr, ".");
}

From source file:org.thoughtland.xlocation.Util.java

public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
        mLogDetermined = true;/*from w w w.  j a v a2  s  .  co  m*/
        try {
            mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false);
        } catch (Throwable ignored) {
            mLog = false;
        }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
        if (hook == null)
            Log.println(priority, "XLocation", msg);
        else
            Log.println(priority, String.format("XLocation/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (uid > 0 && priority == Log.ERROR)
        if (PrivacyService.isRegistered())
            PrivacyService.reportErrorInternal(msg);
        else
            try {
                IPrivacyService client = PrivacyService.getClient();
                if (client != null)
                    client.reportError(msg);
            } catch (RemoteException ignored) {
            }
}

From source file:biz.bokhorst.xprivacy.Util.java

public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
        mLogDetermined = true;//from  w w  w  . j a va 2 s . co  m
        try {
            mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false);
        } catch (Throwable ignored) {
            mLog = false;
        }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
        if (hook == null)
            Log.println(priority, "XPrivacy", msg);
        else
            Log.println(priority, String.format("XPrivacy/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (uid > 0 && priority == Log.ERROR)
        if (PrivacyService.isRegistered())
            PrivacyService.reportErrorInternal(msg);
        else
            try {
                IPrivacyService client = PrivacyService.getClient();
                if (client != null)
                    client.reportError(msg);
            } catch (RemoteException ignored) {
            }
}

From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java

@Test
public void formatEscapesCarriageReturnInMessage() throws IOException {
    final String message = "xxx \r xxx";
    final String expected = "xxx \\r xxx";
    final JsonLog log = getLog(Log.INFO, "tag", message, new RuntimeException());

    assertThat(log.message, is(equalTo(expected)));
}

From source file:com.andresrcb.gcmtest.LoggingService.java

private void doLog(Intent intent) {
    int priority = intent.getIntExtra(EXTRA_LOG_PRIORITY, Log.INFO);
    String msg = intent.getStringExtra(EXTRA_LOG_MESSAGE);

    // Make the log available through adb logcat
    Log.println(priority, LOG_TAG, msg);

    // Add the timestamp to the message
    String timestamp = dateFormat.format(new Date());
    msg = timestamp + " " + msg;

    // Forward the log to LocalBroadcast subscribers (i.e. UI)
    Intent localIntent = new Intent(ACTION_LOG);
    localIntent.putExtra(EXTRA_LOG_MESSAGE, msg);
    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);

    // Write log to file
    try {/*w  w  w  .  j a va  2  s.c  o  m*/
        FileOutputStream outputFile = openFileOutput(LOG_FILE, MODE_APPEND);
        outputFile.write(msg.getBytes());
        outputFile.write(LOG_SEPARATOR.getBytes());
        outputFile.close();
    } catch (IOException ex) {
        Log.e(LOG_TAG, "Error while writing in the log file", ex);
    }
}

From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java

@Test
public void formatEscapesTabInMessage() throws IOException {
    final String message = "xxx \t xxx";
    final String expected = "xxx \\t xxx";
    final JsonLog log = getLog(Log.INFO, "tag", message, new RuntimeException());

    assertThat(log.message, is(equalTo(expected)));
}

From source file:nl.frankkie.bronylivewallpaper.CLog.java

public static void i(String tag, String msg) {
    if (shouldLog && errorLevel <= Log.INFO) {
        Log.i(tag, msg);
    }
}

From source file:com.irccloud.android.IRCCloudApplicationBase.java

@Override
public void onCreate() {
    super.onCreate();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        TrustKit.initializeWithNetworkSecurityConfiguration(getApplicationContext(),
                R.xml.network_security_config);
    Fabric.with(this, new Crashlytics());
    Crashlytics.log(Log.INFO, "IRCCloud", "Crashlytics Initialized");
    FlowManager.init(this);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (Build.VERSION.SDK_INT >= 19)
        EmojiCompat.init(/*from w w  w .  ja va 2  s  . c  om*/
                new BundledEmojiCompatConfig(this).setReplaceAll(!prefs.getBoolean("preferSystemEmoji", true)));
    /*EmojiCompat.init(new FontRequestEmojiCompatConfig(getApplicationContext(), new FontRequest(
            "com.google.android.gms.fonts",
            "com.google.android.gms",
            "Noto Color Emoji Compat",
            R.array.com_google_android_gms_fonts_certs))
            .setReplaceAll(!prefs.getBoolean("preferSystemEmoji", true))
            .registerInitCallback(new EmojiCompat.InitCallback() {
                @Override
                public void onInitialized() {
                    super.onInitialized();
                    EventsList.getInstance().clearCaches();
                    conn.notifyHandlers(NetworkConnection.EVENT_FONT_DOWNLOADED, null);
                }
            }));*/
    NetworkConnection.getInstance().registerForConnectivity();

    //Disable HTTP keep-alive for our app, as some versions of Android will return an empty response
    System.setProperty("http.keepAlive", "false");

    //Allocate all the shared objects at launch
    conn = NetworkConnection.getInstance();
    ColorFormatter.init();

    if (prefs.contains("notify")) {
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString("notify_type", prefs.getBoolean("notify", true) ? "1" : "0");
        editor.remove("notify");
        editor.commit();
    }

    if (prefs.contains("notify_sound")) {
        SharedPreferences.Editor editor = prefs.edit();
        if (!prefs.getBoolean("notify_sound", true))
            editor.putString("notify_ringtone", "");
        editor.remove("notify_sound");
        editor.commit();
    }

    if (prefs.contains("notify_lights")) {
        SharedPreferences.Editor editor = prefs.edit();
        if (!prefs.getBoolean("notify_lights", true))
            editor.putString("notify_led_color", "0");
        editor.remove("notify_lights");
        editor.commit();
    }

    if (!prefs.getBoolean("ringtone_migrated", false)) {
        if (ActivityCompat.checkSelfPermission(this,
                android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            String notification_uri = prefs.getString("notify_ringtone", "");
            if (notification_uri.startsWith("content://media/external/audio/media/")) {
                Cursor c = getContentResolver().query(Uri.parse(notification_uri),
                        new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);

                if (c != null && c.moveToFirst()) {
                    if (c.getString(0).equals("IRCCloud")) {
                        Log.d("IRCCloud", "Migrating notification ringtone setting: " + notification_uri);
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.remove("notify_ringtone");
                        editor.commit();
                    }
                }
                if (c != null && !c.isClosed()) {
                    c.close();
                }
            }

            File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS);
            File file = new File(path, "IRCCloud.mp3");
            if (file.exists()) {
                file.delete();
            }

            try {
                getContentResolver().delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Audio.Media.TITLE + " = 'IRCCloud'", null);
            } catch (Exception e) {
                // Ringtone not in media DB
            }
        }

        try {
            String notification_uri = prefs.getString("notify_ringtone", "");
            if (notification_uri.startsWith("content://media/")) {
                Cursor c = getContentResolver().query(Uri.parse(notification_uri),
                        new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);

                if (c != null && c.moveToFirst()) {
                    if (c.getString(0).equals("IRCCloud")) {
                        Log.d("IRCCloud", "Migrating notification ringtone setting: " + notification_uri);
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.remove("notify_ringtone");
                        editor.commit();
                    }
                }
                if (c != null && !c.isClosed()) {
                    c.close();
                }
            }
        } catch (Exception e) {
            //We might not have permission to query the media DB
        }

        try {
            getContentResolver().delete(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,
                    MediaStore.Audio.Media.TITLE + " = 'IRCCloud'", null);
        } catch (Exception e) {
            // Ringtone not in media DB
            e.printStackTrace();
        }

        File file = new File(getFilesDir(), "IRCCloud.mp3");
        if (file.exists()) {
            file.delete();
        }

        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean("ringtone_migrated", true);
        editor.commit();
    }

    if (prefs.contains("notify_pebble")) {
        try {
            int pebbleVersion = getPackageManager().getPackageInfo("com.getpebble.android", 0).versionCode;
            if (pebbleVersion >= 553 && Build.VERSION.SDK_INT >= 18) {
                SharedPreferences.Editor editor = prefs.edit();
                editor.remove("notify_pebble");
                editor.commit();
            }
        } catch (Exception e) {
        }
    }

    if (prefs.contains("acra.enable")) {
        SharedPreferences.Editor editor = prefs.edit();
        editor.remove("acra.enable");
        editor.commit();
    }

    if (prefs.contains("notifications_json")) {
        SharedPreferences.Editor editor = prefs.edit();
        editor.remove("notifications_json");
        editor.remove("networks_json");
        editor.remove("lastseeneids_json");
        editor.remove("dismissedeids_json");
        editor.commit();
    }

    prefs = getSharedPreferences("prefs", 0);
    if (prefs.getString("host", "www.irccloud.com").equals("www.irccloud.com") && !prefs.contains("path")
            && prefs.contains("session_key")) {
        Crashlytics.log(Log.INFO, "IRCCloud", "Migrating path from session key");
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString("path", "/websocket/" + prefs.getString("session_key", "").charAt(0));
        editor.commit();
    }
    if (prefs.contains("host") && prefs.getString("host", "").equals("www.irccloud.com")) {
        Crashlytics.log(Log.INFO, "IRCCloud", "Migrating host");
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString("host", "api.irccloud.com");
        editor.commit();
    }
    if (prefs.contains("gcm_app_version")) {
        SharedPreferences.Editor editor = prefs.edit();
        editor.remove("gcm_app_version");
        editor.remove("gcm_app_build");
        editor.remove("gcm_registered");
        editor.remove("gcm_reg_id");
        editor.commit();
    }

    NetworkConnection.IRCCLOUD_HOST = prefs.getString("host", BuildConfig.HOST);
    NetworkConnection.IRCCLOUD_PATH = prefs.getString("path", "/");

    /*try {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE))
            WebView.setWebContentsDebuggingEnabled(true);
    }
    } catch (Exception e) {
    }*/

    /*FontRequest request = new FontRequest(
        "com.google.android.gms.fonts",
        "com.google.android.gms",
        "Dekko",
        R.array.com_google_android_gms_fonts_certs);
            
    FontsContractCompat.requestFont(getApplicationContext(), request, new FontsContractCompat.FontRequestCallback() {
    @Override
    public void onTypefaceRetrieved(Typeface typeface) {
        csFont = typeface;
        EventsList.getInstance().clearCaches();
        NetworkConnection.getInstance().notifyHandlers(NetworkConnection.EVENT_FONT_DOWNLOADED, null);
    }
    }, getFontsHandler());*/

    Crashlytics.log(Log.INFO, "IRCCloud", "App Initialized");
}

From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java

@Test
public void formatEscapesNewLineInMessage() throws IOException {
    final String message = "xxx \n xxx";
    final String expected = "xxx \\n xxx";
    final JsonLog log = getLog(Log.INFO, "tag", message, new RuntimeException());

    assertThat(log.message, is(equalTo(expected)));
}

From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java

@Test
public void formatAllowsQuoteInMessage() throws IOException {
    final String message = "xxx \" xxx \"";
    final String expected = "xxx \" xxx \"";
    final JsonLog log = getLog(Log.INFO, "tag", message, new RuntimeException());

    assertThat(log.message, is(equalTo(expected)));
}