-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add commands for AuditLogging #108
Conversation
import org.wildfly.extras.creaper.core.offline.OfflineCommand; | ||
import org.wildfly.extras.creaper.core.online.OnlineCommand; | ||
|
||
public abstract class AbstractSyslogHandlerCommand implements OnlineCommand, OfflineCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it really be public
?
I like this, mostly. The command names are too generic -- I started to comment about that, but I'd have to add a comment to all commands :-) The names must be more specific. Ideally, all would contain the phrase Good job on test coverage :-) |
Also, I'm not very familiar with audit logging. How does it work? That would explain the structure of the commands. So for audit logging, you first configure a formatter (do we have/need commands for that?), then a handler (which refers to a formatter) and finally a logger (which refers to a handler)? I guess that some javadocs for the commands would help. And if you add the |
Thank you very much for the first review :) There is always only one
The default configuration then looks following: <audit-log>
<formatters>
<json-formatter name="json-formatter"/>
</formatters>
<handlers>
<file-handler name="file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.server.data.dir"/>
</handlers>
<logger log-boot="true" log-read-only="false" enabled="false">
<handlers>
<handler name="file"/>
</handlers>
</logger>
</audit-log> I'll create an entrypoint class with javadoc in next commit. Thanks once again for the review. |
Aha. If there's always exactly one logger, why do we have commands |
Oh, I'm terribly sorry. I definitely should have written at most one logger instead of exactly one. In that case it makes IMHO sense to keep both commands. |
OK, what happens if I try to EDIT: I mean, clearly audit loggers are different from other resources for which we have the |
It will fail with |
I wonder if it would make sense to keep That would not be very future-proof, though, in case the ability to add more audit loggers will be added some time in the future... In the end, I think I agree that we should probably keep |
return AuditLogHandler.INSTANCE; | ||
} | ||
|
||
// --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also appears on other places in this class.
The // ---
comment is my personal habit, I don't require anyone to use it.
Generally, all Otherwise looks good. I'll have to have a look at the API in my IDE, but I feel like there are no blockers now. Oh and BTW, if you push new commits, I don't get a notification. Please always add a comment when you want me to have a look. Just saying "PTAL" is enough. |
Ok, final modifiers added/removed and AbstractAuditLogSyslogReliableProtocolCommand removed as well. |
OK, I do see some similarities in the Another option that comes to mind -- would it make sense to merge those 3 classes into one? |
I don't think so. IMO UDP is quite different in comparison to TLS. This would bring necessity to properly document each builder method in style this parameter can be used only with TCP and UDP and user could be easily confused. |
|
||
/** | ||
* <b>Note that when enabled, this can cause server reload!</b> | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment belongs to the replaceExisting
method.
Yea, totally agree -- we should have |
this.truncate = builder.truncate; | ||
this.replaceExisting = builder.replaceExisting; | ||
this.host = builder.host; | ||
this.port = builder.port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also have a single constructor that would take AbstractBuilder
and set all these common fields. It would be called at the beginning of these 3 constructors, saving a bit of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have changed constructors to current state because otherwise I was getting: variable XYZ might already have been assigned
or variable XYZ might not have been assigned
respectively. I'm not sure about the code cleanliness though. Any ideas are welcome ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, true, the fun with definite assignment rules :-( I think 3 different constructors, each for one builder, are better, even with slight code duplication.
Once you address the last comments, could you please squash? I'd like to do a final round of review, and it's easier like that for me :-) I don't expect any big findings, this seems very good now. |
PTAK |
Should the |
Ok, I rewrote one occurrence of Much more importantly: I also added an option for removing handlers that IMHO might be useful. What do you think? |
List<String> auxList = new ArrayList<String>(); | ||
auxList.addAll(addHandlers); | ||
auxList.removeAll(removeHandlers); | ||
if (auxList.size() < addHandlers.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set<String> intersection = new HashSet<String>(addHandlers);
intersection.retainAll(removeHandlers);
if (!intersection.isEmpty()) { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also Sets.intersection
in Guava, but that requires to create two sets instead of one, so I'd prefer to use what I wrote above.
Aye, I thought that |
The change from |
Damn, I didn't notice usage of |
Ah, right you are! If you have no other plans, please squash. |
squashed |
Please rebase. This should be the last time, promise :-) |
aaand rebased :-) |
Please remind me again -- what's EDIT: it seems to be covered by |
The |
Otherwise this is good to merge. |
Thank you, Squashed once more |
Ah, I thought that the UDP/TCP/TLS variants are used and the generic variant is unused. The opposite variant is actually better, I like 3 removed files :-) Thanks, LGTM now. |
Merged, thanks for all the work :-) I know it's been a long time, but rest assured that there were PRs that took even longer to merge :-) |
Thank you. |
If you feel like breaking the record, please submit a PR that touches 100 or 200 files :-) |
No description provided.