@Override public List<LogEntry> listLog(UUID subscriptionId, String serviceName) throws AzureCmdException, ParseException { String[] cmd = new String[] { "mobile", "log", "--json", "-s", subscriptionId.toString(), serviceName, }; String json = AzureCommandHelper.getInstance().consoleExec(cmd); CustomJsonSlurper slurper = new CustomJsonSlurper(); Map<String, Object> results = (Map<String, Object>) slurper.parseText(json); List<Map<String, String>> tempRes = (List<Map<String, String>>) results.get("results"); List<LogEntry> res = new ArrayList<LogEntry>(); for (Map<String, String> item : tempRes) { LogEntry logEntry = new LogEntry(); logEntry.setMessage(item.get("message")); logEntry.setSource(item.get("source")); logEntry.setType(item.get("type")); SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH); logEntry.setTimeCreated(ISO8601DATEFORMAT.parse(item.get("timeCreated"))); res.add(logEntry); } return res; }
@Override public void fail(Object id) { List<LogEntry> list = new ArrayList<LogEntry>(); LogEntry log = new LogEntry(); log.setCategory("Storm"); String message = (String) id; log.setMessage( "FAIL " + message + " " + syinfo.getFQDN() + " CURTIME=" + System.currentTimeMillis()); list.add(log); try { if (!tr.isOpen()) tr.open(); client.Log(list); } catch (org.apache.thrift.TException e) { e.printStackTrace(); } }