Skip to content

Commit

Permalink
Merge pull request #601 from oceanprotocol/improve-readme
Browse files Browse the repository at this point in the history
Improve & simplify readme
  • Loading branch information
mihaisc authored Aug 15, 2024
2 parents 31c7bed + dcfd168 commit ae99b14
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 441 deletions.
458 changes: 67 additions & 391 deletions README.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dashboard/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Dashboard

The static dashbaord files are included in ocean nodes so the dashboard doesn't have to be rebuilt every time the node is built. If there are changes to the dashboard it will be built by default with the Ocean Node. There is a [script](scripts/dashboardChanges.js) running to check for changes in this directory.

When you start your node the dashboard will be made available at: `http://localhost:8000/dashboard/`

## Local development

This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started
Expand Down
File renamed without changes.
102 changes: 102 additions & 0 deletions docs/Logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Logs

Refer to Logs section in the [environmental variables documentation](env.md#logs) for information on how to configure the logs.

## Log Retrieval using HTTP

### Get Multiple Logs

HTTP GET /logs

This endpoint retrieves multiple log entries based on various query parameters. If query parameters are not provided, it defaults to the last 24 hours of logs and a maximum of 100 log entries. Please replace the `startTime`, `endTime` values with actual data as per your requirement when making requests.

**Query Parameters:**

- `startTime` (optional): The start time for logs retrieval in ISO 8601 format.
- `endTime` (optional): The end time for logs retrieval in ISO 8601 format.
- `maxLogs` (optional): The maximum number of log entries to retrieve.
- `moduleName` (optional): The module name to filter the logs.
- `level` (optional): The log level to filter the logs (e.g., "info", "error").

**Example Request:**

```http
GET /logs?startTime=2023-01-01T00:00:00Z&endTime=2023-01-02T00:00:00Z&maxLogs=50&moduleName=auth&level=info
```

**Example Response:**

```json
[
{
"timestamp": 1700569124922,
"level": "info",
"message": "User logged in successfully.",
"moduleName": "HTTP"
},
{
"timestamp": 1700569124922,
"level": "info",
"message": "Session refreshed.",
"moduleName": "HTTP"
}
// More log entries...
]
```

If no logs are found for the given criteria, you will receive a `404 Not Found` response.

### Get a Single Log by ID

HTTP GET /log/:id

This endpoint retrieves a single log entry by its unique identifier.

**Path Parameters:**

- `id`: The unique identifier of the log entry.

Example Request:

```http
GET /log/123456789
```

```json
{
"id": "1",
"level": "info",
"message": "NEW Test log message 1700569124912",
"timestamp": 1700569124922,
"moduleName": "HTTP"
}
```

If the log with the given ID is not found, you will receive a `404 Not Found` response. For server errors, you will receive a `500 Internal Server Error` response.

## Log Retrieval Using Script

The logging system provides a convenient way to retrieve logs via a command-line script. The script is capable of fetching logs with various filters, such as start time, end time, maximum number of logs, module name, and log level.

**Usage**
You can call the script directly from your command line with optional parameters to filter the logs. The parameters are as follows:

- `API_URL`: The URL of the logs API endpoint. Defaults to http://localhost:8000.
- `START_TIME`: The start time for the logs you want to retrieve. Defaults to 24 hours before the current time.
- `END_TIME`: The end time for the logs you want to retrieve. Defaults to the current time.
- `MAX_LOGS`: The maximum number of logs to retrieve. Defaults to 100.
- `MODULE_NAME`: The specific module name to filter the logs. Optional.
- `LEVEL`: The specific log level to filter the logs. Optional.

**Example Without Parameters (Uses Defaults):**

```bash
npm run logs
```

**Example With Specific Parameters:**

```
npm run logs http://localhost:8000 "2023-11-01T00:00:00Z" "2023-11-30T23:59:59Z" 50 "http" "info"
```
3 changes: 3 additions & 0 deletions env.md → docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/
- `RATE_DENY_LIST`: Blocked list of IPs and peer IDs. Example: `"{ \"peers\": [\"16Uiu2HAkuYfgjXoGcSSLSpRPD6XtUgV71t5RqmTmcqdbmrWY9MJo\"], \"ips\": [\"127.0.0.1\"] }"`
- `MAX_REQ_PER_SECOND`: Number of requests per second allowed by the same client. Example: `3`
- `MAX_CHECKSUM_LENGTH`: Define the maximum length for a file if checksum is required (Mb). Example: `10`

## Logs

- `LOG_LEVEL`: Define the default log level. Example: `debug`
- `LOG_CONSOLE`: Write logs to the console. Default is `false`, but becomes `true` if neither `LOG_FILES` or `LOG_DB` are set.
- `LOG_FILES`: Write logs to files. Default is `false`
Expand Down
Loading

0 comments on commit ae99b14

Please sign in to comment.