ekaterinadimitrova2 commented on a change in pull request #1051:
URL: https://github.com/apache/cassandra/pull/1051#discussion_r688182267



##########
File path: src/java/org/apache/cassandra/audit/AuditLogOptions.java
##########
@@ -37,11 +46,242 @@
     public String included_users = StringUtils.EMPTY;
     public String excluded_users = StringUtils.EMPTY;
 
-    /**
-     * AuditLogs directory can be configured using `cassandra.logdir.audit` or 
default is set to `cassandra.logdir` + /audit/
-     */
-    public String audit_logs_dir = System.getProperty("cassandra.logdir.audit",
-                                                      
System.getProperty("cassandra.logdir",".")+"/audit/");
+    public String audit_logs_dir;
+
+    public AuditLogOptions()
+    {
+        String auditLogDir = 
CassandraRelevantProperties.LOG_DIR_AUDIT.getString();
+        String logDir = CassandraRelevantProperties.LOG_DIR.getString() + 
"/audit";
+        Path path = auditLogDir == null ? Paths.get(logDir) : 
Paths.get(auditLogDir);
+        audit_logs_dir = path.normalize().toString();
+    }
+
+    public static AuditLogOptions validate(final AuditLogOptions options) 
throws ConfigurationException
+    {
+        // not validating keyspaces nor users on purpose,
+        // logging might be enabled on these entities before they exist
+        // so they are picked up automatically
+
+        validateCategories(options.included_categories);
+        validateCategories(options.excluded_categories);
+
+        // other fields in BinLogOptions are validated upon BinAuditLogger 
initialisation
+
+        return options;
+    }
+
+    public static class Builder
+    {
+        private boolean enabled;
+        private ParameterizedClass logger;
+        private String includedKeyspaces;
+        private String excludedKeyspaces;
+        private String includedCategories;
+        private String excludedCategories;
+        private String includedUsers;
+        private String excludedUsers;
+        private String auditLogDir;
+        private int maxQueueWeight;
+        private int maxArchiveRetries;
+        private String rollCycle;
+        private String archiveCommand;
+        private boolean block;
+        private long maxLogSize;
+
+        public Builder()
+        {
+            this(new AuditLogOptions());
+        }
+
+        public Builder(final AuditLogOptions opts)
+        {
+            this.enabled = opts.enabled;
+            this.logger = opts.logger;
+            this.includedKeyspaces = opts.included_keyspaces;
+            this.excludedKeyspaces = opts.excluded_keyspaces;
+            this.includedCategories = opts.included_categories;
+            this.excludedCategories = opts.excluded_categories;
+            this.includedUsers = opts.included_users;
+            this.excludedUsers = opts.excluded_users;
+            this.auditLogDir = opts.audit_logs_dir;
+            this.maxQueueWeight = opts.max_queue_weight;
+            this.maxArchiveRetries = opts.max_archive_retries;
+            this.rollCycle = opts.roll_cycle;
+            this.archiveCommand = opts.archive_command;
+            this.block = opts.block;
+            this.maxLogSize = opts.max_log_size;
+        }
+
+        public Builder withEnabled(boolean enabled)
+        {

Review comment:
       For the record; the FQL builder is missing the with prefix but I think 
your naming convention is better 👍 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to