ActionLogMessageFactory { public ActionLogMessage create(ActionLog log) { var message = new ActionLogMessage(); message.app = LogManager.APP_NAME; message.host = Network.LOCAL_HOST_NAME; message.id = log.id; message.date = log.date; message.result = log.result(); message.correlationIds = log.correlationIds; message.clients = log.clients; message.refIds = log.refIds; message.elapsed = log.elapsed; message.action = log.action; message.errorCode = log.errorCode(); message.errorMessage = log.errorMessage; message.context = log.context; message.stats = log.stats; message.performanceStats = performanceStats(log.performanceStats); if (log.flushTraceLog()) { message.traceLog = trace(log, SOFT_TRACE_LIMIT, HARD_TRACE_LIMIT); } return message; }  ActionLogMessage create(ActionLog log);  }
@Test void actionLog() { var log = new ActionLog("begin", null); log.action("action"); log.process(new LogEvent("logger", Markers.errorCode("ERROR_CODE"), LogLevel.WARN, "message", null, null)); log.track("db", 1000, 1, 2); log.track("http", 2000, 0, 0); ActionLogMessage message = factory.create(log); assertThat(message).isNotNull(); assertThat(message.app).isEqualTo(LogManager.APP_NAME); assertThat(message.action).isEqualTo("action"); assertThat(message.errorCode).isEqualTo("ERROR_CODE"); assertThat(message.traceLog).isNotEmpty(); PerformanceStatMessage stats = message.performanceStats.get("db"); assertThat(stats.totalElapsed).isEqualTo(1000); assertThat(stats.count).isEqualTo(1); assertThat(stats.readEntries).isEqualTo(1); assertThat(stats.writeEntries).isEqualTo(2); stats = message.performanceStats.get("http"); assertThat(stats.totalElapsed).isEqualTo(2000); assertThat(stats.count).isEqualTo(1); assertThat(stats.readEntries).isNull(); assertThat(stats.writeEntries).isNull(); }