ActionLog { public void stat(String key, double value) { stats.compute(key, (k, oldValue) -> (oldValue == null) ? value : oldValue + value); var format = new DecimalFormat(); add(event("[stat] {}={}", key, format.format(value))); } ActionLog(String message, String id); long elapsed(); String errorCode(); void context(String key, Object... values); void stat(String key, double value); int track(String operation, long elapsed, int readEntries, int writeEntries); String correlationId(); void action(String action); final String id; final Map<String, List<String>> context; final Map<String, Double> stats; final Instant date; public boolean trace; public String action; public List<String> correlationIds; public List<String> clients; public List<String> refIds; public boolean suppressSlowSQLWarning; }
@Test void stat() { log.stat("stat", 1); assertThat(log.stats.get("stat").intValue()).isEqualTo(1); log.stat("stat", 1); assertThat(log.stats.get("stat").intValue()).isEqualTo(2); }