grails-audit-logging-plugin icon indicating copy to clipboard operation
grails-audit-logging-plugin copied to clipboard

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

Open dmahapatro opened this issue 8 years ago • 7 comments

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

dmahapatro avatar Aug 18 '16 19:08 dmahapatro

Requirement:

  1. orm-independent way
  2. independent of mapping config

robertoschwald avatar Aug 18 '16 20:08 robertoschwald

@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.

dmahapatro avatar Aug 19 '16 01:08 dmahapatro

Would be great if you can form a PR.

robertoschwald avatar Aug 19 '16 06:08 robertoschwald

Sure. Will work on it over the weekend.

dmahapatro avatar Aug 19 '16 11:08 dmahapatro

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.

dmahapatro avatar Aug 21 '16 23:08 dmahapatro

Any news on this? Will you provide a PR?

robertoschwald avatar Mar 20 '17 08:03 robertoschwald

@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.

robertoschwald avatar Jun 07 '17 14:06 robertoschwald