I have installed the audit-logging
plugin into my application. The grails version is 2.1.1
and the plugin version is 1.0.1
.
In my Config.groovy
class, I have added this
auditLog {
verbose = true // verbosely log all changed values to db
logIds = true // log db-ids of associated objects.
// Note: if you change next 2 properties, you must update your database schema!
tablename = 'audit_logs' // table name for audit logs.
transactional = false
actorClosure = { request, session ->
org.apache.shiro.SecurityUtils.getSubject()?.getPrincipal()
}
and in my domain class I have added this
class Survey {
static auditable = true
static final int NO_RUNNING_SURVERY = 0
static final int RUNNING_SURVERY = 1
static final int CALL_NO_Record_SURVEY = 0
static final int CALL_Record_SURVEY = 1
static final int REALTIME_SURVEY = 0
static final int HISTORICAL_SURVEY = 1
static final int STANDARD_SURVERY = 2
String name
String description
int status
}
when I add, delete and update some thing.
In my audit_logs
table, double record inserted against one operation e.g.
If I change the status value from my controller class
def stopSurvey(Long id) {
def survey = Survey.findById(params['stop'])
survey.status = Survey.NO_RUNNING_SURVERY
redirect(action: "list")
}
it inserts two records per call.
Didn't see this behaviour here, too. Using this plugin in many projects. Can you please set verbose=false and test again? If the problem happens then also, it means the events might be fired not only once.
A small testapp would be great.
BTW: We use spock tests in the plugins project contained test application (audit-test) to check for how many events are stored in the audit_log table. Therefore I assume an edge case or a specific problem in your app.