Version: 5.xx.xx
useLog
If you need to create or update an audit log, you can use Refine's useLog
hook. This hook will return two mutations called log
and rename
import { useLog } from "@refinedev/core";
const { log, rename } = useLog();
logโ
The log
mutation is used to create an audit log event using the create
method from auditLogProvider
under the hood.
import { useLog } from "@refinedev/core";
const { log } = useLog();
const { mutate } = log;
mutate({
resource: "posts",
action: "create",
author: {
username: "admin",
},
data: {
id: 1,
title: "New post",
},
meta: {
id: 1,
},
});
Propertiesโ
Property | Type |
---|---|
resource ๏นก | string |
action ๏นก | string |
author | Record<string, any> |
meta | Record<string, any> |
data | Record<string, any> |
previousData | Record<string, any> |
Type Parametersโ
Property | Description | Type | Default |
---|---|---|---|
TData | Result data of the mutation. Extends BaseRecord | BaseRecord | BaseRecord |
TError | Custom error object that extends HttpError | HttpError | HttpError |
TVariables | Values for mutation function | {} | {} |
Return valueโ
Description | Type |
---|---|
Result of the react-query 's useMutation | UseMutationResult<{ data: TData}, TError, { id: BaseKey; name: string; }, unknown> |
renameโ
The rename
mutation is used to update an audit log event using the update
method from auditLogProvider
under the hood.
import { useLog } from "@refinedev/core";
const { rename } = useLog();
const { mutate } = rename;
mutate({
id: 1,
name: "Updated Name",
});
Propertiesโ
Property | Type |
---|---|
id ๏นก | BaseKey |
name ๏นก | string |
Type Parametersโ
Property | Description | Type | Default |
---|---|---|---|
TData | Result data of the mutation. Extends BaseRecord | BaseRecord | BaseRecord |
TError | Custom error object that extends HttpError | HttpError | HttpError |
TVariables | Values for mutation function | {} | {} |
Return valueโ
Description | Type |
---|---|
Result of the react-query 's useMutation | UseMutationResult<{ data: TData}, TError, { id: BaseKey; name: string; }, unknown> |