public static void log(Logger logger, Reason reason, String message, Type type, ObjectKind objectKind, String objectName) { String line = String.format("%s (kind=%s name=%s): %s", reason.name(), objectKind.name(), objectName, message); switch (type) { case Warning: logger.warn(line); break; case Normal: logger.info(line); break; } } }
String timestamp = Instant.now(clock).toString(); try { if (existing != null && existing.getType().equals(type.name()) && existing.getReason().equals(reason.name()) && existing.getInvolvedObject().getName().equals(objectName) && existing.getInvolvedObject().getKind().equals(objectKind.name())) { existing.setCount(existing.getCount() + 1); existing.setLastTimestamp(timestamp); .endMetadata() .withCount(1) .withReason(reason.name()) .withMessage(message) .withType(type.name())