public void removeEntriesWithPathForAuthor(String path, String author) { if (logEntries == null || logEntries.isEmpty()) { return; } int count = logEntries.size(); int i = 0; while (i < count) { LogEntry logEntry = logEntries.get(i); if (!logEntry.getAuthor().equals(author)) { i++; continue; } logEntry.removeEntriesWithPath(path); if (logEntry.isEmpty()) { logEntries.remove(logEntry); count--; continue; } i++; } isOrdered = false; }
private void writeLogEntry(PrintWriter out, LogEntry logEntry) { if (logEntry.getEntriesCount() == 0) { return; } String message = logEntry.getMessage().replace(QUOTE_CHARACTER, QUOTE_SPECIAL_CHARACTER); message = message.replace(ANGLE_OPENING_BRACKET_CHARACTER, ANGLE_OPENING_BRACKET_SPECIAL_CHARACTER); message = message.replace(ANGLE_CLOSING_BRACKET_CHARACTER, ANGLE_CLOSING_BRACKET_SPECIAL_CHARACTER); out.println( MessageFormat.format( LOGENTRY_START_NODE, new String[] {message, Integer.toString(logEntry.getRevision()), logEntry.getDate()})); List<PathEntry> pathEntries = logEntry.getPathEntries(); for (PathEntry pathEntry : pathEntries) { out.println( MessageFormat.format( PATH_NODE, new String[] {pathEntry.getAction(), pathEntry.getPath()})); } out.println(LOGENTRY_END_NODE); }
public void removeNotLastModifications() { List<String> uniquePaths = getUniquePaths(); for (String path : uniquePaths) { int lastRevision = getLastModificationRevisionForPath(path); int count = logEntries.size(); int i = 0; while (i < count) { LogEntry entry = logEntries.get(i); if (entry.getRevision() < lastRevision) { entry.removeEntriesWithPath(path); if (entry.isEmpty()) { logEntries.remove(entry); count--; i--; } } i++; } } isOrdered = false; }
@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; }
public static List<String> convert(List<LogEntry> entries) { List<String> strings = new ArrayList<String>(); for (LogEntry entry : entries) { strings.add(entry.toString()); } return strings; }
public static Multimap<String, LogEntry> groupByIPAddress(Collection<LogEntry> entries) { Multimap<String, LogEntry> ip2Entries = TreeMultimap.create(); for (LogEntry entry : entries) { ip2Entries.put(entry.getIp(), entry); } return ip2Entries; }
public static Multimap<String, LogEntry> groupByUserAgent(Collection<LogEntry> entries) { Multimap<String, LogEntry> userAgent2Entries = TreeMultimap.create(); for (LogEntry entry : entries) { userAgent2Entries.put(entry.getUserAgent(), entry); } return userAgent2Entries; }
public static Multimap<Date, LogEntry> groupByTime(Collection<LogEntry> entries) { Multimap<Date, LogEntry> time2Entries = TreeMultimap.create(); for (LogEntry entry : entries) { time2Entries.put(entry.getDate(), entry); } return time2Entries; }
public static LogEntry constructLogEntry( int aId, int aType, int aLogGroup, String aMain, String aDateTime, String aExt1, String aExt2, String aExt3) { LogEntry ret = null; switch (aType) { case EMPTY_ENTRY: ret = new EmptyLogEntry(); break; case SPEED_ENTRY: try { ret = new SpeedLogEntry(aLogGroup, aMain, aDateTime); } catch (Exception e) { e.printStackTrace(); } break; case GROUP_INFO_ENTRY: ret = new GroupInfoEntry(aLogGroup, aMain); break; } ret.mId = aId; return ret; }
@Override @Transactional(propagation = Propagation.REQUIRED) public void logGet(LogEntry.ActionType action, String username) { LogEntry entry = new LogEntry(); entry.setAction(action); entry.setUsername(username); entityManager.persist(entry); }
/** * @param level {@link Level} The level to filter the log entries. * @return all log entries for that level and above. */ public List<LogEntry> filter(Level level) { List<LogEntry> toReturn = new ArrayList<LogEntry>(); for (LogEntry entry : entries) { if (entry.getLevel().intValue() >= level.intValue()) { toReturn.add(entry); } } return toReturn; }
public static LogEntry parseDump(HashMap<String, String> dump) { LogEntry build = new LogEntry(Boolean.parseBoolean(dump.get("LoggingIn?"))); try { build.timeframe = parser.parse(dump.get("Time")); } catch (ParseException e) { e.printStackTrace(); } return build; }
public int getLogEntriesCount() { int count = 0; for (LogEntry logEntry : logEntries) { count += logEntry.getEntriesCount(); } return count; }
public LogEntry getLogEntryByRevision(int revision) { for (LogEntry logEntry : logEntries) { if (logEntry.getRevision() == revision) { return logEntry; } } return null; }
private static void addEntry(T tag, LogLevel level, String text) { // skip if recording is disabled (default) if (!mEnableRecording) return; LogEntry entry = new LogEntry(); entry.logLevel = level; entry.logText = text; entry.logTag = tag; mLogEntries.addEntry(entry); }
/** * Create a new loggable object for the given type. * * @param type * @param transactId the id of the current transaction. * @throws LogException */ public static final Loggable create(byte type, DBBroker broker, long transactId) throws LogException { LogEntry entry = (LogEntry) entryTypes.get(type); if (entry == null) return null; try { return entry.newInstance(broker, transactId); } catch (Exception e) { throw new LogException("Failed to create log entry object", e); } }
public LogReport getLogReportForAuthor(String author) { LogReport report = new LogReport(); for (LogEntry entry : logEntries) { if (entry.getAuthor().equals(author)) { report.addLogEntry(entry); } } return report.isEmpty() ? null : report; }
void log(int op, Object el) { LogEntry entry = new LogEntry(); entry.op = op; entry.el = el; List<LogEntry> log = txManager.getContext().getCurrent().getTopLevel().getAttribute(S); if (log == null) { log = new ArrayList<LogEntry>(); txManager.getContext().getCurrent().getTopLevel().setAttribute(S, log); } log.add(entry); }
public int getAuthorLogEntriesCount(String author) { List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author); int count = 0; for (LogEntry logEntry : logEntries) { count += logEntry.getEntriesCount(); } return count; }
private List<LogEntry> getUnorderedAuthorLogEntries(String author) { List<LogEntry> entries = new LinkedList<LogEntry>(); for (LogEntry logEntry : logEntries) { if (logEntry.getAuthor().equals(author)) { entries.add(logEntry); } } return entries; }
/** * Checks if the given list of strings occur in the given order among the given log messages (one * string per message). * * @param entries The list of log entries. * @param expected The array of expected strings. * @return true if a match was found for all expected strings, otherwise false. */ private boolean containsExpectedEntries(ImmutableList<LogEntry> entries, String[] expected) { int index = 0; for (LogEntry entry : entries) { if (index == expected.length) { return true; } if (!entry.getMessage().contains(expected[index])) { index++; } } return (index == expected.length); }
static void debugDump(PrintWriter out) { for (int i = 0; i < sMusicLog.length; i++) { int idx = (sLogPtr + i); if (idx >= sMusicLog.length) { idx -= sMusicLog.length; } LogEntry entry = sMusicLog[idx]; if (entry != null) { entry.dump(out); } } }
public void test() throws Exception { Database db = getJDOManager(DBNAME, MAPPING).getDatabase(); db.begin(); LOG.info("Begin transaction to query log entries"); OQLQuery oql = db.getOQLQuery("SELECT e FROM " + LogEntry.class.getName() + " e"); QueryResults results = oql.execute(); while (results.hasMore()) { LogEntry entry = (LogEntry) results.next(); int id = entry.getId().intValue(); boolean isRefering = (entry instanceof ReferingLogEntry); boolean isException = (entry.getException() != null); if (LOG.isDebugEnabled()) { LOG.debug(id + "/" + isRefering + "/" + isException); } switch (id) { case 1: case 2: case 7: case 9: case 10: case 12: case 15: assertFalse(isRefering); assertFalse(isException); break; case 3: case 4: case 8: case 13: assertFalse(isRefering); assertTrue(isException); break; case 5: case 6: case 11: case 14: assertTrue(isRefering); assertFalse(isException); break; default: fail(); } } LOG.info("End transaction to query log entries"); db.commit(); db.close(); }
@Override public void endLog(boolean success) throws IOException { List<LogEntry> filtered = interceptor.apply(logEntries); delegate.startLog(); for (LogEntry entry : filtered) { entry.accept(delegate); } delegate.endLog(success); logEntries.clear(); }
public List<String> getAuthors() { List<String> authors = new LinkedList<String>(); for (LogEntry logEntry : logEntries) { if (!authors.contains(logEntry.getAuthor())) { authors.add(logEntry.getAuthor()); } } Collections.sort(authors); return authors; }
public void log(LogEntry entry) { NoExRun.wrap( () -> { String query = "insert into usage_log(action_date, username, method, user_action) values(?, ?, ?, ?);"; PreparedStatement stm = connection.getConnection().prepareStatement(query); stm.setTimestamp(1, new Timestamp(entry.getDate().getTime())); stm.setString(2, entry.getUsername()); stm.setString(3, entry.getMethod()); stm.setString(4, entry.getAction()); return stm.execute(); }) .get(); }
public SvnFileRevision( SvnVcs vcs, SVNRevision pegRevision, LogEntry logEntry, String url, String copyFromPath) { final SVNRevision revision = SVNRevision.create(logEntry.getRevision()); myRevisionNumber = new SvnRevisionNumber(revision); myPegRevision = pegRevision; myRevision = revision; myAuthor = logEntry.getAuthor(); myDate = logEntry.getDate(); myCommitMessage = logEntry.getMessage(); myCopyFromPath = copyFromPath; myVCS = vcs; myURL = url; myMergeSources = new ArrayList<>(); }
public List<String> getUniquePaths() { List<String> uniquePathEntries = new LinkedList<String>(); for (LogEntry logEntry : logEntries) { List<PathEntry> pathEntries = logEntry.getPathEntries(); for (PathEntry pathEntry : pathEntries) { if (!uniquePathEntries.contains(pathEntry.getPath())) { uniquePathEntries.add(pathEntry.getPath()); } } } return uniquePathEntries; }
public List<PathEntry> getOrderedByRevisionAuthorPathEntries(String author) { List<PathEntry> orderedPathEntries = new LinkedList<PathEntry>(); List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author); for (LogEntry logEntry : logEntries) { List<PathEntry> pathEntries = logEntry.getPathEntries(); for (PathEntry pathEntry : pathEntries) { orderedPathEntries.add(pathEntry); } } Collections.sort(orderedPathEntries); return orderedPathEntries; }
public int getLastModificationRevisionForPath(String path) { int revision = -1; for (LogEntry logEntry : logEntries) { List<PathEntry> pathEntries = logEntry.getPathEntries(); for (PathEntry pathEntry : pathEntries) { if (pathEntry.getPath().equals(path) && revision < pathEntry.getRevision()) { revision = pathEntry.getRevision(); break; } } } return revision; }