symentis / grails-audit-logging-plugin

The Grails Audit Logging Plugin
Apache License 2.0
50 stars 59 forks source link

Ability to log actual table name and column name instead of property name and domain class name respectively #122

Open dmahapatro opened 8 years ago

dmahapatro commented 8 years ago

It will an useful enhancement if we can add configurations like grails.plugin.auditLog.logTableName and grails.plugin.auditLog.logColumnName to capture the actual table name and column name respectively.

They (actual names and domain class property names) can be mutually exclusive or both inclusive if required. That can also be driven by a config item. That is, either we have one or the other or we can have both properties and actual names. Thoughts?

For example, considering the below Book domain class;

class Book {
    String name

    static mapping = {
        table 'BOOK'
        name column: 'BOOK_NAME'
    }
}

We can have either Book as the CLASS_NAME in the AUDIT_LOG table or BOOK (actual table name) as CLASS_NAME in AUDIT_LOG table. It would be nice if we capture both. That would need adding a new column to the AUDIT_LOG table named TABLE_NAME. Same goes with PROPERTY_NAME and COLUMN_NAME

robertoschwald commented 8 years ago

Requirement:

  1. orm-independent way
  2. independent of mapping config
dmahapatro commented 8 years ago

@robertoschwald Let me know if you want me to send a PR. You mentioned you think about the table name column over the weekend, but if you want I can send the changes related to COLUMN_NAME column.

robertoschwald commented 8 years ago

Would be great if you can form a PR.

dmahapatro commented 8 years ago

Sure. Will work on it over the weekend.

dmahapatro commented 8 years ago

I have a working solution for COLUMN_NAME as property name in my forked repo. I have an integration test which fails because I am unable to set the config property in integration test.

This test should pass because I have used it in a similar way in other applications with Grails 3.1.9. I will look into it more.

robertoschwald commented 7 years ago

Any news on this? Will you provide a PR?

robertoschwald commented 7 years ago

@dmahapatro I think setting in applicationContext config is too late at that point. See the new TruncateSpec how I change it directly in the listeners. https://github.com/robertoschwald/grails-audit-logging-plugin/blob/master/audit-test/src/integration-test/groovy/test/AuditTruncateSpec.groovy#L136

Please mark it the same way as I did to avoid people to do this nasty thing in real live. thx.