Example usage for android.util Log ASSERT

List of usage examples for android.util Log ASSERT

Introduction

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

Prototype

int ASSERT

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

Click Source Link

Document

Priority constant for the println method.

Usage

From source file:com.example.android.common.logger.LogView.java

/**
 * Formats the log data and prints it out to the LogView.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 *///from  ww  w .j a  va  2  s  .c  o m
@Override
public void println(int priority, String tag, String msg, Throwable tr) {

    String priorityStr = null;

    // For the purposes of this View, we want to print the priority as readable text.
    switch (priority) {
    case android.util.Log.VERBOSE:
        priorityStr = "VERBOSE";
        break;
    case android.util.Log.DEBUG:
        priorityStr = "DEBUG";
        break;
    case android.util.Log.INFO:
        priorityStr = "INFO";
        break;
    case android.util.Log.WARN:
        priorityStr = "WARN";
        break;
    case android.util.Log.ERROR:
        priorityStr = "ERROR";
        break;
    case android.util.Log.ASSERT:
        priorityStr = "ASSERT";
        break;
    default:
        break;
    }

    // Handily, the Log class has a facility for converting a stack trace into a usable string.
    String exceptionStr = null;
    if (tr != null) {
        exceptionStr = android.util.Log.getStackTraceString(tr);
    }

    // Take the priority, tag, message, and exception, and concatenate as necessary
    // into one usable line of text.
    final StringBuilder outputBuilder = new StringBuilder();

    String delimiter = "\t";
    appendIfNotNull(outputBuilder, priorityStr, delimiter);
    appendIfNotNull(outputBuilder, tag, delimiter);
    appendIfNotNull(outputBuilder, msg, delimiter);
    appendIfNotNull(outputBuilder, exceptionStr, delimiter);

    // In case this was originally called from an AsyncTask or some other off-UI thread,
    // make sure the update occurs within the UI thread.
    ((Activity) getContext()).runOnUiThread((new Thread(new Runnable() {
        @Override
        public void run() {
            // Display the text we just generated within the LogView.
            appendToLog(outputBuilder.toString());
        }
    })));

    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}

From source file:es.uva.tel.gte.cardiomanager.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.slide_main);

    // Comprobamos la alarma que nos indica si se ha cerrado o no la aplicacin
    DBAdapter dbAdapter = new DBAdapter(getApplicationContext());
    dbAdapter.open();/*  w  ww  .ja va 2 s. c o  m*/

    boolean alarmUp = isMyServiceRunning(AppService.class);

    if (alarmUp) {
        // No se ha cerrado la aplicacin
        Log.println(Log.ASSERT, "Main Activity", "La alarma estaba activa");
    } else {
        Log.println(Log.ASSERT, "Main Activity", "Activamos alarma");
        // Se ha cerrado la aplicacion
        // Volvemos a poner la alarma
        Intent intent = new Intent(getApplicationContext(), CheckAlarmsService.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 123456789, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.YEAR, 1); // Alarma a 1 ao, tiempo suficiente 
        Log.println(Log.ASSERT, "Alarm Created", "Alarm Created");
        AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 1000 * 60,
                pendingIntent);
        // Comprobamos ahora cuantos medicamentos no se han tomado
        startService(intent);

    }

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);

    fManager = getSupportFragmentManager();

    Cursor cursor = dbAdapter.fetchAllRows(DBAdapter.TABLE_NAME_POLITICS_ACCEPTED);
    if (cursor.moveToFirst()) {
        if (cursor.getInt(1) == 1 && cursor.getInt(2) == 1) {
            // Accepted
        } else {
            // Mostrar dilogo
            PoliticDialog newFragment = new PoliticDialog();
            newFragment.show(fManager, "Tag");
        }
    } else {
        // Mostrar dilogo
        PoliticDialog newFragment = new PoliticDialog();
        newFragment.show(fManager, "Tag");
    }
    dbAdapter.close();

}

From source file:es.uva.tel.gte.cardiomanager.main.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    // TODO Auto-generated method stub
    super.onConfigurationChanged(newConfig);
    Log.println(Log.ASSERT, "DEBUG", "ConfigChangdeddd");
}

From source file:com.scvngr.levelup.core.util.LogManager.java

/**
 * Logs a message to the Android log.//  w w w. j av a2 s .c om
 *
 * @param logLevel {@link Log#VERBOSE}, {@link Log#DEBUG}, {@link Log#INFO}, {@link Log#WARN},
 *        or {@link Log#ERROR}.
 * @param message the message to be logged. This message is expected to be a format string if
 *        messageFormatArgs is not null.
 * @param messageFormatArgs formatting arguments for the message, or null if the string is to be
 *        handled without formatting.
 * @param err an optional error to log with a stacktrace.
 */
private static void logMessage(final int logLevel, @NonNull final String message,
        @Nullable final Object[] messageFormatArgs, @Nullable final Throwable err) {
    final String preppedMessage = formatMessage(message, messageFormatArgs);

    final StackTraceElement[] trace = Thread.currentThread().getStackTrace();
    final String sourceClass = trace[STACKTRACE_SOURCE_FRAME_INDEX].getClassName();
    final String sourceMethod = trace[STACKTRACE_SOURCE_FRAME_INDEX].getMethodName();

    final String logcatLogLine = String.format(Locale.US, FORMAT, Thread.currentThread().getName(), sourceClass,
            sourceMethod, preppedMessage);

    switch (logLevel) {
    case Log.VERBOSE: {
        if (null == err) {
            Log.v(sLogTag, logcatLogLine);
        } else {
            Log.v(sLogTag, logcatLogLine, err);
        }
        break;
    }
    case Log.DEBUG: {
        if (null == err) {
            Log.d(sLogTag, logcatLogLine);
        } else {
            Log.d(sLogTag, logcatLogLine, err);
        }
        break;
    }
    case Log.INFO: {
        if (null == err) {
            Log.i(sLogTag, logcatLogLine);
        } else {
            Log.i(sLogTag, logcatLogLine, err);
        }
        break;
    }
    case Log.WARN: {
        if (null == err) {
            Log.w(sLogTag, logcatLogLine);
        } else {
            Log.w(sLogTag, logcatLogLine, err);
        }
        break;
    }
    case Log.ERROR: {
        if (null == err) {
            Log.e(sLogTag, logcatLogLine);
        } else {
            Log.e(sLogTag, logcatLogLine, err);
        }
        break;
    }
    case Log.ASSERT: {
        if (null == err) {
            Log.wtf(sLogTag, logcatLogLine);
        } else {
            Log.wtf(sLogTag, logcatLogLine, err);
        }
        break;
    }
    default: {
        throw new AssertionError();
    }
    }
}

From source file:org.andstatus.app.util.MyLog.java

private static String getMinLogLevel(SharedPreferences sp) {
    String val;
    try {/*from   ww w .jav  a  2 s  .c o  m*/
        /**
         * Due to the Android bug
         * ListPreference operate with String values only...
         * See http://code.google.com/p/android/issues/detail?id=2096
         */
        val = sp.getString(MyPreferences.KEY_MIN_LOG_LEVEL, String.valueOf(Log.ASSERT));
        minLogLevel = Integer.parseInt(val);
    } catch (java.lang.ClassCastException e) {
        minLogLevel = sp.getInt(MyPreferences.KEY_MIN_LOG_LEVEL, Log.ASSERT);
        val = Integer.toString(minLogLevel);
        Log.e(TAG, MyPreferences.KEY_MIN_LOG_LEVEL + "='" + val + "'", e);
    }
    return val;
}

From source file:br.com.anteros.android.synchronism.communication.AndroidHttpClient.java

/**
 * Enables cURL request logging for this client.
 * /*from ww  w. j  a v  a2s .  c o  m*/
 * @param name
 *            to log messages with
 * @param level
 *            at which to log messages (see {@link android.util.Log})
 */
public void enableCurlLogging(String name, int level) {
    if (name == null) {
        throw new NullPointerException("name");
    }
    if (level < Log.VERBOSE || level > Log.ASSERT) {
        throw new IllegalArgumentException("Level is out of range [" + Log.VERBOSE + ".." + Log.ASSERT + "]");
    }

    curlConfiguration = new LoggingConfiguration(name, level);
}