List Logs
This command allows you to retrieve a paginated list of audit logs from your DID Space. You can filter the logs based on various criteria such as status and action type, and also specify pagination and sorting options. This is crucial for monitoring activities and ensuring accountability within your DID Space.
For an overview of all Audit Log commands, refer to the Audit Log section.
Parameters#
Name | Type | Description | Default |
---|---|---|---|
|
| The number of audit log entries to return per page. |
|
|
| The page number of the results to retrieve (0-indexed). |
|
|
| The field by which to sort the audit log entries. For example, |
|
|
| The sort order: |
|
|
| Optional. Filter logs by their status. Can be a single | |
|
| Optional. Filter logs by their action type. Can be a single |
Returns#
Name | Type | Description |
---|---|---|
|
| The HTTP status code of the response. |
|
| The HTTP status message. |
|
| An object containing the list of audit log entries and pagination information. |
data
Object Structure
Name | Type | Description |
---|---|---|
|
| An array of audit log entry objects. The precise structure of |
|
| The total number of audit log entries matching the criteria. |
|
| The current page number of the results. |
|
| The number of items per page. |
Return Value Example
{
"statusCode": 200,
"statusMessage": "OK",
"data": {
"data": [
{
"id": "some-log-id-1",
"action": "ObjectPut",
"status": "Success",
"timestamp": "2023-10-27T10:00:00Z",
"details": {
"path": "/my-space/documents/report.pdf",
"size": 10240,
"did": "did:abt:zxxxx"
}
},
{
"id": "some-log-id-2",
"action": "FolderSyncPush",
"status": "Failed",
"timestamp": "2023-10-27T10:05:00Z",
"details": {
"folder": "/local/data",
"error": "Insufficient space"
}
}
],
"total": 2,
"page": 0,
"size": 10
}
}
Example#
This example demonstrates how to retrieve the first page of audit logs, filtered by a specific action type and sorted by timestamp in descending order.
import { SpaceClient } from '@did-space/client';
import { AuditLogAction, AuditLogStatus } from '@did-space/constants'; // Assuming these are imported from constants
async function listAuditLogs() {
try {
const client = new SpaceClient({
// Configure your client, e.g., did: 'did:abt:zabc...'
// The DID Space endpoint is typically configured here or via environment variables.
});
const logs = await client.auditLog.list({
page: 0,
size: 5,
sort: 'timestamp',
order: 1, // Descending
actionType: AuditLogAction.ObjectPut,
status: [AuditLogStatus.Success, AuditLogStatus.Failed]
});
console.log(`Found ${logs.data.total} audit logs.`);
logs.data.data.forEach(log => {
console.log(`- ID: ${log.id}, Action: ${log.action}, Status: ${log.status}, Timestamp: ${log.timestamp}`);
});
} catch (error) {
console.error('Error listing audit logs:', error.message);
}
}
listAuditLogs();
This example fetches the first 5 audit log entries, specifically looking for ObjectPut
actions that either succeeded or failed, ordered from newest to oldest. The actual AuditLogAction
and AuditLogStatus
enum values would be imported from the @did-space/constants
package.
Now that you understand how to retrieve audit logs, you might want to learn how to record the initiation and update the status of object synchronization processes. Proceed to the Post Sync command documentation.