Skip to content
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

GPAUDITLOGGING-35: Allow global audit logging setting #17

Closed
robertoschwald opened this issue Apr 19, 2012 · 4 comments
Closed

GPAUDITLOGGING-35: Allow global audit logging setting #17

robertoschwald opened this issue Apr 19, 2012 · 4 comments

Comments

@robertoschwald
Copy link
Contributor

Original Reporter: eceres
Environment: Not Specified
Version: Grails-AuditLogging 0.5.4
Migrated From: http://jira.grails.org/browse/GPAUDITLOGGING-35

Currently each gorm object needs to have the auditable value set. Would be easier and more consistent to set a global default auditable state in Config.groovy that gets applied to all objects. This is helpful if you can not modify all gorm objects but want universal logging, have a lot of gorm objects to modify, or want to ensure future compliance. Each gorm object can over-ride the default behavior to change/turn it off the same as current configuration for audit logging.

The provided patch is consistent with the current behavior if Config.groovy does not get added defaults. Then modifying Config.groovy will allow setting the 4 main settings of audit logging via different parameters.

Example of new Config.groovy settings allowed from this patch:

auditLog {
auditableDefault = true
handlersOnlyDefault = true
ignoreDefault = ['version','lastUpdated','ignoreMe']
defaultHandlerClosure = { request, session, handler, entity, oldMap, newMap ->
print "Handler called for ${entity.class.toString()} object due to change of ${handler}"
}
}

auditableDefault - can be true or false. If false (standard behavior) will only log for classes with static auditable defined. If true then will log for any class that does not set static auditable = false.

handlersOnlyDefault - can be true or false. If false (standard behavior) will continue to log as normal. If true will not carry out the logging except on any class with static auditable = [handlersOnly:false]

ignoreDefault - takes a list that will be the default fields ignored. If not provided will be ['version', 'lastUpdated'] like the current version. Like other properties setting ignore: in the static auditable will use that over the default.

defaultHandlerClosure - A closure that will be called if the gorm object does not have the proper on method (onChange, onSave, onDelete). The closure takes 5 parameters as shown in above example. The handler value will be a string equal to the on method that was not provided.

@robertoschwald
Copy link
Contributor Author

hartsock said:
I like this idea.

@robertoschwald
Copy link
Contributor Author

william added a comment - 06/Apr/15 6:07 AM
Hi guys, any luck?

@robertoschwald
Copy link
Contributor Author

Related to #43

@robertoschwald
Copy link
Contributor Author

Obsolete with the new TraitInjector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant