Skip to main content

Logs

Qore\Next\System\Models\Log stores audit-style entries for a model.

Logs are shown through the resource logbook modal on detail pages and are usually written through qore()->logger().

What The Model Stores​

Log stores:

  • entity_type and entity_id for the model being logged;
  • user_id for the user responsible for the change;
  • description for the event name;
  • field, value_old and value_new for field-level mutations;
  • payload for action or workflow data.

The payload attribute is cast to array.

Writing Logs​

Use the logger service instead of creating Log directly:

qore()->logger()
->setEntity($product)
->setDescription('price_updated')
->setFieldName('price')
->setOldValue($oldPrice)
->setNewValue($newPrice)
->setPayload(['source' => 'manual_review'])
->save();

The service automatically sets the authenticated user ID when there is a logged-in user.

Automatic Logs​

Qore writes logs for common resource flows:

  • resource create, update and delete mutations;
  • field mutation changes;
  • file attachments and removals;
  • relation attach and detach changes;
  • resource action execution.

Field mutation logging compares the original model value with the new model value and skips the log when nothing changed.

Resource Logbook​

The default detail page always adds a logbook item to the actions dropdown. It opens a modal table with:

  • date;
  • user;
  • description;
  • field;
  • new value;
  • old value.

ID is available in the table settings, but hidden by default. Long or multiline new and old values are shown as compact previews with a separate dialog for inspecting the full content.

The table query is scoped to the current detail model:

Log::query()->whereMorphedTo('entity', $model);

Descriptions​

Use stable descriptions such as price_imported, approved or the values from ResourceMutationDescription.

Avoid putting long human text in description; put detailed context in payload so the log stays filterable and consistent.