List of usage examples for java.lang Throwable printStackTrace
public void printStackTrace()
From source file:models.data.providers.LogProvider.java
/** * 20131009: add delete archived date folders * /*from w ww . j a v a 2 s . c o m*/ * @param dateForArchive * @param logFolder */ public static void deleteFilesForOneLogFolderOnDate(String dateForArchive, String logFolder) { try { String destDirPath = generateAppLogRelativeFolderDate(dateForArchive, logFolder); FileIoUtils.deleteAllFileAndDirInFolder(destDirPath); } catch (Throwable e) { e.printStackTrace(); models.utils.LogUtils .printLogError("Error in deleteFilesForLogsOnDate " + DateUtils.getNowDateTimeStrSdsm()); } }
From source file:com.rsegismont.androlife.core.utils.AndrolifeUtils.java
public static Cursor getAndrolifeCursor(Uri paramUri, Context paramContext, int paramInt, String[] paramArrayOfString, Calendar... paramVarArgs) { try {/* w w w .j a va 2s . c o m*/ String[][] arrayOfString = getCursorValues(paramContext, paramInt, paramVarArgs); Cursor localCursor = paramContext.getContentResolver().query(paramUri, paramArrayOfString, arrayOfString[0][0], arrayOfString[1], SharedInformation.DatabaseColumn.DATE_UTC.stringValue + " ASC"); return localCursor; } catch (Throwable localThrowable) { localThrowable.printStackTrace(); } return null; }
From source file:com.rsegismont.androlife.core.utils.AndrolifeUtils.java
public static Loader<Cursor> getAndrolifeLoader(Context paramContext, int paramInt, String[] paramArrayOfString, Calendar... paramVarArgs) { try {//from ww w . ja v a2 s . co m String[][] arrayOfString = getCursorValues(paramContext, paramInt, paramVarArgs); CursorLoader localCursorLoader = new CursorLoader(paramContext, SharedInformation.CONTENT_URI_PROGRAMMES, paramArrayOfString, arrayOfString[0][0], arrayOfString[1], SharedInformation.DatabaseColumn.DATE_UTC.stringValue + " ASC"); return localCursorLoader; } catch (Throwable localThrowable) { localThrowable.printStackTrace(); } return null; }
From source file:models.data.providers.LogProvider.java
/** * 20130923 generic save object as json file * // w ww . j a v a 2 s .c o m * @param filePath * @param object */ public static void saveJsonDataInLog(String filePath, Object object) { try { if (filePath == null) { models.utils.LogUtils.printLogError("Error filePath is null insaveJsonDataInLog "); } else { writeObjectAsJsonFile(object, filePath); } } catch (Throwable t) { t.printStackTrace(); models.utils.LogUtils .printLogError(("Error occured in saveJsonDataInLog: " + AgentUtils.getStackTraceStr(t))); } }
From source file:io.janusproject.Boot.java
/** Show an error message, and exit. * * @param message - the description of the error. * @param e - the cause of the error.//from w ww .j a v a 2 s . c o m */ protected static void showError(String message, Throwable e) { if (message != null && !message.isEmpty()) { //CHECKSTYLE:OFF System.err.println(message); //CHECKSTYLE:ON } if (e != null) { //CHECKSTYLE:OFF e.printStackTrace(); //CHECKSTYLE:ON } showHelp(); }
From source file:models.data.providers.LogProvider.java
public static String readJsonLog(String nodeGroupType, String agentCommandType, String timeStamp) { String logContent = null;//from w ww . ja v a2 s . c o m try { if (nodeGroupType == null || agentCommandType == null || timeStamp == null) { models.utils.LogUtils .printLogError("Error nodeGroupType is null or agentCommandType or timeStamp is null "); } else { LogFile logFile = new LogFile(timeStamp, nodeGroupType, agentCommandType); String filePath = logFile.genLogFilePath(); logContent = FileIoUtils.readFileToString(filePath); } } catch (Throwable t) { t.printStackTrace(); models.utils.LogUtils .printLogError(("Error occured in readJsonLog: " + AgentUtils.getStackTraceStr(t))); } return logContent; }
From source file:models.data.providers.LogProvider.java
public static boolean archiveAppLogsOnDate(String archiveDate) { boolean success = true; try {/*w w w . ja v a2 s .c o m*/ LogProvider.moveFilesForAppLogs(archiveDate, VarUtils.LOG_FOLDER_NAME_APP_WITH_SLASH); // 2013094: add other log folders LogProvider.moveFilesForAppLogs(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_WITH_SLASH); LogProvider.moveFilesForAppLogs(archiveDate, VarUtils.LOG_FOLDER_NAME_NONESTARDARD_WITH_SLASH); LogProvider.moveFilesForAppLogs(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_COMPONENTS_AGGREGATION_RULES + "/"); LogProvider.moveFilesForAppLogs(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_COMPONENTS_COMMANDS + "/"); LogProvider.moveFilesForAppLogs(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_COMPONENTS_NODE_GROUPS + "/"); models.utils.LogUtils.printLogNormal("Success archive app logs into folder " + archiveDate); } catch (Throwable t) { t.printStackTrace(); models.utils.LogUtils.printLogNormal("Error occured in archive app logs "); success = false; } return success; }
From source file:models.data.providers.LogProvider.java
public static void saveAgentDataInLog(String nodeGroupType, String agentCommandType, Map<String, NodeGroupDataMap> dataStore) { try {/*from w w w . j a va2 s . co m*/ models.utils.LogUtils.printLogNormal("Start to write log files for nodeGroupType: " + nodeGroupType + " agentCommandType: " + agentCommandType + " at " + DateUtils.getNowDateTimeStrSdsm()); if (nodeGroupType == null || agentCommandType == null) { models.utils.LogUtils.printLogError( "Error nodeGroupType is null or agentCommandType is null in saveAgentDataInLog. Will not to save logs.. " + DateUtils.getNowDateTimeStrSdsm()); } else { String logFilePath = genLogFilePath(nodeGroupType, agentCommandType, dataStore); writeObjectAsJsonFile( dataStore.get(nodeGroupType).getNodeGroupDataMapValidForSingleCommand(agentCommandType), logFilePath); } } catch (Throwable t) { t.printStackTrace(); models.utils.LogUtils .printLogError(("Error occured in saveAgentDataInLog: " + AgentUtils.getStackTraceStr(t))); } }
From source file:models.data.providers.LogProvider.java
public static boolean deleteAllAppLogsOnDate(String archiveDate) { boolean success = true; try {// w w w . j a v a2 s .c o m LogProvider.deleteFilesForOneLogFolderOnDate(archiveDate, VarUtils.LOG_FOLDER_NAME_APP_WITH_SLASH); // 2013094: add other log folders LogProvider.deleteFilesForOneLogFolderOnDate(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_WITH_SLASH); LogProvider.deleteFilesForOneLogFolderOnDate(archiveDate, VarUtils.LOG_FOLDER_NAME_NONESTARDARD_WITH_SLASH); LogProvider.deleteFilesForOneLogFolderOnDate(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_COMPONENTS_AGGREGATION_RULES + "/"); LogProvider.deleteFilesForOneLogFolderOnDate(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_COMPONENTS_COMMANDS + "/"); LogProvider.deleteFilesForOneLogFolderOnDate(archiveDate, VarUtils.LOG_FOLDER_NAME_ADHOC_COMPONENTS_NODE_GROUPS + "/"); models.utils.LogUtils .printLogNormal("Success deleteAllAppLogsOnDate app logs with date " + archiveDate); } catch (Throwable t) { t.printStackTrace(); models.utils.LogUtils .printLogNormal("Error occured in deleteAllAppLogsOnDate; ErrMsg: " + t.getLocalizedMessage()); success = false; } return success; }
From source file:models.data.providers.LogProvider.java
/** * Read JSON log to the hashmap. From file back to the memory. * //from w w w. j a v a 2 s . c om * @param nodeGroupType * @param agentCommandType * @param timeStamp * @return */ public static Map<String, NodeData> readJsonLogToNodeDataMap(String nodeGroupType, String agentCommandType, String timeStamp) { String logContent = readJsonLog(nodeGroupType, agentCommandType, timeStamp); HashMap<String, NodeData> nodeDataMapValid = null; if (logContent == null) { models.utils.LogUtils.printLogError("Error logContent is null in readJsonLogToNodeDataMap "); return nodeDataMapValid; } try { // Great solution: very challenging part: 20130523 // http://stackoverflow.com/questions/2779251/convert-json-to-hashmap-using-gson-in-java GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Object.class, new NaturalDeserializer()); Gson gson = gsonBuilder.create(); Object mapObject = gson.fromJson(logContent, Object.class); nodeDataMapValid = (HashMap<String, NodeData>) (mapObject); if (VarUtils.IN_DETAIL_DEBUG) { models.utils.LogUtils.printLogNormal(nodeDataMapValid.size() + ""); } } catch (Throwable e) { e.printStackTrace(); } return nodeDataMapValid; }