Skip to content

Commit

Permalink
Enable SSE logs only on GUI flag and misc reviewers comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed May 17, 2023
1 parent 5eeca70 commit 9f5ca3d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3750,7 +3750,7 @@ pub fn serve<T: BeaconChainTypes>(
}
}
Err(e) => Err(warp_utils::reject::server_sent_event_error(
format!("Unable to serialize to JSON {}", e),
format!("Unable to receive event {}", e),
)),
}
});
Expand Down Expand Up @@ -3929,4 +3929,4 @@ fn publish_network_message<T: EthSpec>(
e
))
})
}
}
4 changes: 2 additions & 2 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.long("gui")
.hidden(true)
.help("Enable the graphical user interface and all its requirements. \
This is equivalent to --http and --validator-monitor-auto.")
This enables --http and --validator-monitor-auto and enables SSE logging.")
.takes_value(false)
)
.arg(
Expand All @@ -1093,4 +1093,4 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
// always using the builder.
.conflicts_with("builder-profit-threshold")
)
}
}
5 changes: 2 additions & 3 deletions book/src/api-lighthouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ Caveats:

This is a Server Side Event subscription endpoint. This allows a user to read
the Lighthouse logs directly from the HTTP API endpoint. This currently
exposes INFO and higher level logs.
exposes INFO and higher level logs. It is only enabled when the `--gui` flag is set in the CLI.

Example:

Expand All @@ -694,7 +694,7 @@ curl -N "http://localhost:5052/lighthouse/logs"

Should provide an output that emits log events as they occur:
```json
{
{
"data": {
"time": "Mar 13 15:28:41",
"level": "INFO",
Expand All @@ -707,4 +707,3 @@ Should provide an output that emits log events as they occur:
}
}
```

6 changes: 3 additions & 3 deletions book/src/api-vc-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ logs emitted are INFO level or higher.

| Property | Specification |
|-------------------|--------------------------------------------|
| Path | `/lighthouse/logs` |
| Path | `/lighthouse/logs` |
| Method | GET |
| Required Headers | [`Authorization`](./api-vc-auth-header.md) |
| Required Headers | None |
| Typical Responses | 200 |

### Example Response Body
Expand All @@ -607,4 +607,4 @@ logs emitted are INFO level or higher.
"total": 1
}
}
```
```
4 changes: 2 additions & 2 deletions common/logging/src/sse_logging_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ impl Drain for SSELoggingComponents {

fn log(&self, record: &Record, logger_values: &OwnedKVList) -> Result<Self::Ok, Self::Err> {
if record.level().is_at_least(LOG_LEVEL) {
// There are subscribers, attempt to send the logs
// Attempt to send the logs
match self.sender.send(AsyncRecord::from(record, logger_values)) {
Ok(_num_sent) => {} // Everything got sent
Err(_err) => {} // There are no subscribers, do nothing
}
}
Ok(())
}
}
}
2 changes: 1 addition & 1 deletion lighthouse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ fn run<E: EthSpec>(

let sse_logging = {
if let Some(bn_matches) = matches.subcommand_matches("beacon_node") {
bn_matches.is_present("http") || bn_matches.is_present("gui")
bn_matches.is_present("gui")
} else if let Some(vc_matches) = matches.subcommand_matches("validator_client") {
vc_matches.is_present("http")
} else {
Expand Down
4 changes: 2 additions & 2 deletions validator_client/src/http_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
}
}
Err(e) => Err(warp_utils::reject::server_sent_event_error(
format!("Unable to serialize to JSON {}", e),
format!("Unable to receive event {}", e),
)),
}
});
Expand Down Expand Up @@ -1174,4 +1174,4 @@ where

response
})
}
}

0 comments on commit 9f5ca3d

Please sign in to comment.