import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import org.simantics.audit.AuditLogging;
import org.simantics.audit.AuditLogging.Level;
public class AuditLoggingClient {
private static final String AUDIT_SERVER_ADDRESS = "org.simantics.audit.serverAddress";
+ private static final String AUDIT_CLIENT_ID = "org.simantics.audit.clientId";
private static final Logger LOGGER = LoggerFactory.getLogger(AuditLoggingClient.class);
private AuditLoggingAPIClient apiClient;
- private AuditLoggingClient(String serverAddress) throws AuditLoggingException {
- // Read config from sysargs
- apiClient = new AuditLoggingAPIClient("testlog", serverAddress);
+ private AuditLoggingClient(String clientId, String serverAddress) throws AuditLoggingException {
+ apiClient = new AuditLoggingAPIClient(clientId, serverAddress);
}
private static AuditLoggingClient fromEnv() throws AuditLoggingException {
synchronized (AuditLoggingClient.class) {
if (INSTANCE == null) {
String serverAddress = (String) properties.get(AUDIT_SERVER_ADDRESS);
+ String clientId = (String) properties.get(AUDIT_CLIENT_ID);
+ if (clientId == null || clientId.isEmpty())
+ clientId = UUID.randomUUID().toString();
if (serverAddress != null && !serverAddress.isEmpty()) {
- INSTANCE = new AuditLoggingClient(serverAddress);
+ INSTANCE = new AuditLoggingClient(clientId, serverAddress);
} else {
LOGGER.warn("No {} system property defined so client not configured", AUDIT_SERVER_ADDRESS);
}