Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Commands Reference

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

size

number

The number of audit log entries to return per page.

10

page

number

The page number of the results to retrieve (0-indexed).

0

sort

string

The field by which to sort the audit log entries. For example, createdAt, actionType.

''

order

number

The sort order: 0 for ascending, 1 for descending.

0

status

AuditLogStatus or AuditLogStatus[]

Optional. Filter logs by their status. Can be a single AuditLogStatus enum value or an array of values. Refer to the @did-space/constants package for available AuditLogStatus enum values.


actionType

AuditLogAction or AuditLogAction[]

Optional. Filter logs by their action type. Can be a single AuditLogAction enum value or an array of values. Refer to the @did-space/constants package for available AuditLogAction enum values.


Returns#

Name

Type

Description

statusCode

number

The HTTP status code of the response.

statusMessage

string

The HTTP status message.

data

object

An object containing the list of audit log entries and pagination information.

data Object Structure

Name

Type

Description

data

AuditLogEntry[]

An array of audit log entry objects. The precise structure of AuditLogEntry is determined by the DID Space service but typically includes fields like id, action, status, timestamp, and details.

total

number

The total number of audit log entries matching the criteria.

page

number

The current page number of the results.

size

number

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.