Liftweb Traits for logging changes MetaMapper-Records
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Lift Stamped

These traits let you extend your MetaMapper-models to log every change
made by users (and the belonging customers). Tested on liftweb 1.1-M7.

What it does do

  • logging which user/customer changed which record on which class
  • skip logging (initial user creation, for background-job purpose)
  • adds reverse associations so your record has a “logs” method

What it doesn’t do (yet)

  • logging of what changed
  • reverting records according to what was changed
  • reverse associations for the Singleton to get every log associated with that model

Traits for the class

  • CustomerFields: adds a customer-object to the model
  • ActivateFields: adds an active-boolean to the model (with seperate logging)
  • ActionLogs: adds reverse associations to records (not the singleton)

Traits for the singleton

  • Stamped: stamps any changes done to records in that model
  • Activatable: logging for ActivateFields

Stamping a model

class MyModel extends LongKeyedMapper[MyModel]
	with IdPK
	with CustomerFields[MyModel]
	with ActionLogs[MyModel]
	with ActivateFields[MyModel] {
object MyModel extends MyModel with LongKeyedMetaMapper[MyModel]
	with Stamped[MyModel] with Activatable[MyModel]

Initial user creation with logging skipped

In Boot.scala add this:

if (Customer.findAll.length == 0) {
	/* Customer creation */
        Customer.skipLogging = true
        val c = new Customer"First Customer").save
        Customer.skipLogging = false
	/* User creation */
	User.skipLogging = true
        val u = new User
        User.skipLogging = false

Read the sourcecode!

Really, it’s open source for a reason. ;)