Java Code Examples for com.pluscubed.logcat.helper.SaveLogHelper#deleteLogIfExists()
The following examples show how to use
com.pluscubed.logcat.helper.SaveLogHelper#deleteLogIfExists() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogcatRecordingService.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(getApplicationContext()); while ((line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 2
Source File: LogcatRecordingService.java From javaide with GNU General Public License v3.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(getApplicationContext()); while ((line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 3
Source File: LogcatRecordingService.java From matlog with GNU General Public License v3.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(this); String filterPattern = PreferenceHelper.getFilterPatternPreference(this); while (mReader != null && (line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit, filterPattern)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }